Gitlab merge request event webhook sending unexpected payload

I am trying to configure a Gitlab project to trigger a Jenkins job on merge request events. I set up the webhook on my project to call “http://gitlab-server/gitlab/build_now” on “Merge Request Events” per the Jenkins Gitlab Webhook Plugin (https://wiki.jenkins-ci.org/display/JENKINS/Gitlab+Hook+Plugin) documentation. When I run the “Test” on the webhook, it does trigger my Jenkins build. However, on actual merge request events the Jenkins build does not get triggered.

I took a look at the logs in Jenkins (/var/log/jenkins/jenkin.log) to see the POST requests coming from the Gitlab webhook. When I run the “Test”, it actually sends the request as a “Push Event” as follows:

INFO: gitlab web hook triggered for

  • repo url: git@gitlab-server:gps-ocx-ifdc-ci/test_project.git
  • branch: master
  • with payload:
    {
    “object_kind”: “push”,
    “event_name”: “push”,
    “before”: “48d3523fe9bd54eac09a4a227bbf639c5c26f61e”,
    “after”: “3e420436006160854e37a0cb726fcdcae6728a37”,
    “ref”: “refs/heads/master”,
    “checkout_sha”: “3e420436006160854e37a0cb726fcdcae6728a37”,
    “message”: null,
    “user_id”: 11,

When there is an actual merge request event, the request looks like:

INFO:
Mar 17, 2017 4:28:36 PM org.jruby.javasupport.JavaMethod invokeDirectWithExceptionHandling
INFO: gitlab web hook triggered for

  • with payload:
    {
    “id”: 1302,
    “target_branch”: “master”,
    “source_branch”: “develop”,
    “source_project_id”: 583,
    “author_id”: 11,
    “assignee_id”: null,
    “title”: “Develop”,
    “created_at”: “2017-03-17 20:28:36 UTC”,
    “updated_at”: “2017-03-17 20:28:36 UTC”,
    “milestone_id”: null,
    “state”: “opened”,
    “merge_status”: “unchecked”,
    “target_project_id”: 583,
    “iid”: 5,
    “description”: “”,
    “position”: 0,
    “locked_at”: null,
    “updated_by_id”: null,
    “merge_error”: null,
    “merge_params”: {
    “force_remove_source_branch”: null
    },
    “merge_when_build_succeeds”: false,
    “merge_user_id”: null,
    “merge_commit_sha”: null,
    “deleted_at”: null,
    “in_progress_merge_commit_sha”: null,
    “lock_version”: null,
    “time_estimate”: 0,
    “source”: {

However, per the Gitlab documentation, I would expect the payload for the “Merge Request Event” to look much more similar to the “Push Event” request (https://docs.gitlab.com/ce/user/project/integrations/webhooks.html#merge-request-events).

Any idea as to why the POST for “Merge Request Event” would be so different? It appears as though the Jenkins Gitlab Webhook Plugin keys off of particular keys (object_kind and object_attributes namely) and so I believe this is why nothing is getting triggered.

The versions I am using are:
Gitlab CE 8.17.3
Jenkins 1.642.18.3 (CloudBees Jenkins Enterprise 15.11)
Jenkins Gitlab Plugin 1.4.2

Thanks!

I’m getting the same on Gitlab 8.17.8.
All the webhook tests are returning “push” instead of the correct object_kind.
Since my webhook is checking the object_kind, it’s returning error on all except the “push”.

Same is happening in my case. It sends a push webhook for a merge request. Did you guys resolve this