jenkinsci / jenkinsci/gitlab-branch-source-plugin

Build result of MR jobs is reported in the wrong pipeline

Open
#259 5 comments 0 reactions 0 assignees View on GitHub
Dominant language
Java
Stars
134
Forks
113
PR merge metrics
No merged PRs in 30d

Description

### What feature do you want to see added?

We have a setup with a `Jenkinsfile` and we start to migrate step-by-step to GitLab (by adding a `.gitlab-ci.yml` file).

In gitlab some of the jobs have the rule:

```yaml
rules:
- if: $CI_PIPELINE_SOURCE == 'merge_request_event'
```

This creates 2 pipelines in GitLab for a given MR:

Pipeline tab for a MR

* We see that the pipeline at the top is for the MR with IID `1`
* And the one at the button is for the `patch` branch.

In Jenkins we also have this notion of branch jobs and merge-request jobs:

Jenkins view

But all the Jenkins jobs are reported in the same GitLab pipeline (the branch one and not the MR one), see the external stage in the branch pipeline:

External stage in the pipeline

I think the problem is the way this plugin reports the commit status:
https://github.com/jenkinsci/gitlab-branch-source-plugin/blob/dc12a4a064349814682eae6b959a784365aec39c/src/main/java/io/jenkins/plugins/gitlabbranchsource/helpers/GitLabPipelineStatusNotifier.java#L325-L339

### Upstream changes

I could not find an open issue for it, but I think one limitation is that there is no API to report a commit status for an open merge request:

*Set the pipeline status of a commit*
https://docs.gitlab.com/ee/api/commits.html#set-the-pipeline-status-of-a-commit

There you can not set anything about the MR.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.