Allow Jenkins to publish build status to merge request pipelines
Proposal
Send MR head ref in webhook payload to Jenkins, to allow the GitLab plugin to publish the build status back to the MR pipeline.
Supporting MR pipelines for Jenkins build status reporting may also require changes in Jenkins GitLab plugin, which is separate and not in scope of this MR.
Problem
GitLab Jenkins integration sends webhook payload that does not include the MR head ref. When GitLab Jenkins plugin publishes the build status back to GitLab, it uses the source branch in the originating webhook payload. GitLab attempts to find a matching pipeline based on the ref, and if one doesn't exist, it creates one. As the source branch won't match the MR head ref, a new pipeline is always created.
Demonstrate behaviour
- Configure Jenkins with GitLab plugin
- Configure Jenkins project/job to build on push and merge request events
- Configure Jenkins project/job to publish build status back to GitLab
- Configure Jenkins integration on GitLab for push and merge request events
- Create a new branch with a simple
.gitlab-ci.yml
, one job, with a rule to run the job only on MR pipelines - Commit/push branch
- Create an MR
- Confirm GitLab MR pipeline runs, and Jenkins build runs
- Confirm Jenkins build status is reported on newly created MR pipeline with source external, instead of being created in a new Branch pipeline
Edited by Michael Trainor