10

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 is id
  • gitlabTargetBranch is target_branch
  • gitlabSourceBranch is source_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?

3 Answers 3

2

Have a look at the plugin Gitlab Merge Request Builder Plugin.Configure the Jenkins From Manage Jenkins and set gitlab url in merger request builder.Follow the instructions on https://github.com/timols/jenkins-gitlab-merge-request-builder-plugin1

0

Check this new plugin out (gitlab-plugin), maybe it helps. This plugin emulates Jenkins as a GitlabCI Web Service to be used with GitlabHQ.

0

You may use the Generic Webhook Trigger for Jenkins. It can contribute any value from the webhook JSON structure to the build.

https://wiki.jenkins.io/display/JENKINS/Generic+Webhook+Trigger+Plugin

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .