--- title: "ADR 0019: GitLab commit status falls back from source to target project to an MR comment" --- * Status: accepted * Code: [`pkg/provider/gitlab/gitlab.go`](https://github.com/tektoncd/pipelines-as-code/blob/main/pkg/provider/gitlab/gitlab.go) (`CreateStatus`) ## Context On a merge request from a fork, creating a commit status on the fork requires write access there. The token on the Repository CR usually only has access to the upstream project, so the first attempt often fails for permission reasons. On a push or an MR from a branch in the same repository it works. ## Decision * `CreateStatus` tries the source project, then the target project. Errors from the first attempt are only logged at debug level. * If the target attempt fails with `Cannot transition status`, the status is already set, so no MR comment is created and the call returns nil. * Otherwise the error from the target project is the one carried in the `FailedToSetCommitStatus` event and the comment fallback follows. * Statuses for one SHA are put in the same GitLab pipeline: the pipeline ID is read from the PipelineRun annotation `keys.GitLabPipelineID`, else from the in-memory value, and sent as `PipelineID`. * A GitOps command is converted to a pull request event only when `event.TriggerTarget` is already `pull_request`. A command arriving on a pushed commit keeps `TriggerTarget == push` and is not converted, so push payloads do not take the comment path. * `pending` maps to GitLab `running`, as does `Status == "in_progress"`, which is checked again after the conclusion switch and overrides it. ## Consequences * Users whose token cannot write to forks get MR comments instead of pipeline status, plus a `FailedToSetCommitStatus` event telling them to grant access.