I want Jenkins (1.561) to build merge (pull) requests submitted to GitLab (6.7.5), triggered by a merge request web hook. I have a parameterised build, and the Jenkins plugins "GitLab Merge Request Builder" (1.2.0) and "GitLab Hook" (1.0.0). Migrating to Jenkins CI is, unfortunately, not a real option.
The Merge Request Builder plugin is able to build merge requests, as long as the variables gitlabMergeRequestId
, gitlabTargetBranch
, and gitlabSourceBranch
are available. This works well when the plugin polls the repository itself, or I trigger the build with a manual payload (e.g. curl --data "gitlabMergeRequestId=3&so_on http://server_name/job/$JOB_NAME/buildWithParameters
), but I cannot do this with a hook.
Using the GitLab Hook plugin, I am able to get the necessary data in the JSON payload, but the values have "wrong" keys:
gitlabMergeRequestId
isid
gitlabTargetBranch
istarget_branch
gitlabSourceBranch
issource_branch
I have tried configuring build parameters with the GitLab Merge Request Builder plugin's requirements as Name
and variable values as Default Value
. Unfortunately (and probably intentionally), the variables in the Default Value
fields are not replaced, so Jenkins is looking for a merge request with the id ${id}
and similar branch values.
I have found no way of configuring the payload sent from GitLab, and there are no configuration options for neither the GitLab Hook plugin nor the parameter names used by the GitLab Merge Request Builder plugin.
I am considering writing a small PHP script to intercept and alter the payload from the POST before passing it on to Jenkins. While I am sure this will work, it definitely seems unnecessarily complicated.
The only other real option I can see is to alter the source of the plugins, but this makes upgrading them a PITA.
Have I overlooked something obvious, or is there really no simpler way of triggering Merge Request builds with a web hook from GitLab to Jenkins?