0
votes

I'm having an issue when I'm filing a merge request within GitLab. When I file a merge request, I do not get a job built, though I have a webhook to listen for a merge request or a push. Every time I get a push, it does build.

Here's an example of the push request I get from the webhook:

{"before":"bf12dc027feacfb99cd8e24b1be0993d29652e3d","after":"3ec0e32587f999f4edcb7085859a1af94f62c7ad","ref":"refs/heads/DUMMY_foo_bar_test","user_id":14,"user_name":"adam","project_id":9,"repository":{"name":"exchange-api","url":"[email protected]:exchange/exchange-api.git","description":"","homepage":"http://gitlab01.localhost.com/exchange/exchange-api"},"commits":[{"id":"3ec0e32587f999f4edcb7085859a1af94f62c7ad","message":"Fooo bar","timestamp":"2014-10-22T16:14:50-06:00","url":"http://gitlab01.localhost.com/exchange/exchange-api/commit/3ec0e32587f999f4edcb7085859a1af94f62c7ad","author":{"name":"Adam","email":"[email protected]"}}],"total_commits_count":1}

Here is what the Gitlab is sending for a merge_request:

{"object_kind":"merge_request","object_attributes":{"id":117,"target_branch":"US4395_safenet","source_branch":"DUMMY_foo_bar_test","source_project_id":9,"author_id":14,"assignee_id":null,"title":"Dummy foo bar test","created_at":"2014-10-22 21:52:35 UTC","updated_at":"2014-10-22 21:52:35 UTC","milestone_id":null,"state":"opened","merge_status":"unchecked","target_project_id":9,"iid":9,"description":"","position":0}}

When you press "Test Hook" for the merge request, the job builds succesfully and there are no issues, here is the data that gets sent:

{"before":"2ba2af40719a0b14661b5078d2c709fb7814f16f","after":"d27f6559cc4c4a0b4e76a00c21f6848169e1d5ab","ref":"refs/heads/dev_cloud","user_id":14,"user_name":"adam bourg","project_id":9,"repository":{"name":"exchange-api","url":"[email protected]:exchange/exchange-api.git","description":"","homepage":"http://gitlab01.localhost.com/exchange/exchange-api"},"commits":[{"id":"d27f6559cc4c4a0b4e76a00c21f6848169e1d5ab","message":"Merge branch 'dev_cloud' of localhost.com:exchange-api into dev_cloud","timestamp":"2014-10-14T15:53:34-06:00","url":"http://gitlab01.localhost.com/exchange/exchange-api/commit/d27f6559cc4c4a0b4e76a00c21f6848169e1d5ab","author":{"name":"Adam","email":"[email protected]"}},{"id":"ef9eba1cc80b1ca7c9178ee2e6c35908a459b5ea","message":"Merge branch 'qa' into dev_cloud","timestamp":"2014-10-14T15:53:26-06:00","url":"http://gitlab01.localhost.com/exchange/exchange-api/commit/ef9eba1cc80b1ca7c9178ee2e6c35908a459b5ea","author":{"name":"Adam","email":"[email protected]"}},{"id":"2ba2af40719a0b14661b5078d2c709fb7814f16f","message":"US3425: recommender_drug needs plan_id in calculate_listed_pharmacy_cost","timestamp":"2014-10-14T15:53:12-06:00","url":"http://gitlab01.localhost.com/exchange/exchange-api/commit/2ba2af40719a0b14661b5078d2c709fb7814f16f","author":{"name":"Adam","email":"[email protected]"}}],"total_commits_count":3}

Why is the real merge request trigger sending so little data? How can I fix this and get Jenkins to build Correctly for this job?

Jenkins version: 1.584

Gitlab Hook Plugin Version: 1.1.0

Link: https://wiki.jenkins-ci.org/display/JENKINS/Gitlab+Hook+Plugin

1

1 Answers

0
votes

Also, I just played around a bit with this idea.

The scenario I used:

  • branch master
  • branch feature, created from master
  • added a few commits/changes on feature branch
  • pushed feature branch commits
  • no changes on master
  • merge request created in gitlab
  • merge request accepted

On merge request created, gitlab sent merge_request JSON in "unchecked" status and with details about source (feature branch), destination (master) and latest commit on feature branch:

{
    "object_kind": "merge_request",
    "object_attributes":
    {
        "id": 1,
        "target_branch": "master",
        "source_branch": "develop",
        "source_project_id": 1,
        "author_id": 1,
        "assignee_id": 1,
        "title": "Merge test",
        "created_at": "2014-10-26 19:27:54 UTC",
        "updated_at": "2014-10-26 19:27:54 UTC",
        "milestone_id": null,
        "state": "opened",
        "merge_status": "unchecked",
        "target_project_id": 1,
        "iid": 1,
        "description": "",
        "position": 0,
        "source": {
            "name": "jenkins-hooks-test",
            "ssh_url": "[email protected]:root/jenkins-hooks-test.git",
            "http_url": "http://gitlab.local/root/jenkins-hooks-test.git",
            "namespace": "root",
            "visibility_level": 10
        },
        "target": {
            "name": "jenkins-hooks-test",
            "ssh_url": "[email protected]:root/jenkins-hooks-test.git",
            "http_url": "http://gitlab.local/root/jenkins-hooks-test.git",
            "namespace": "root",
            "visibility_level": 10
        },
        "last_commit": {
            "id": "8e71eab5362ef1165b6e233c97f7e9afcdba6485",
            "message": "change\n",
            "timestamp": "2014-10-26T12:11:21-07:00",
            "url": "http://gitlab.local/root/jenkins-hooks-test/commit/8e71eab5362ef1165b6e233c97f7e9afcdba6485",
            "author": {
                "name": "Vanja Radovanovic",
                "email": "[email protected]"
            }
        }
    }
}

There was no job triggered, but in this case it seems to be OK. The reason is that prior to merge request, I pushed changes from feature branch and those got built on Jenkins already. When merge request is issued, there is no need to do a build of that situation.

Then, after accepting the request, it was merged in gitlab. And as a result, a new commit took place (merge commit on master branch), and that triggered the build on Jenkins with:

{
    "before": "62823aa9df67e76c97a22a7229495db51abd6c7f",
    "after": "2edb684defde57dce8344ed5800b5e90e4e18a5d",
    "ref": "refs/heads/master",
    "user_id": 1,
    "user_name": "Administrator",
    "project_id": 1,
    "repository": {
        "name": "jenkins-hooks-test",
        "url": "[email protected]:root/jenkins-hooks-test.git",
        "description": "",
        "homepage": "http://gitlab.local/root/jenkins-hooks-test"
    },
    "commits": [
        {
            "id": "23cb86268570fcf53b59870fb7f4bc2fc5bf1f16",
            "message": "change\n",
            "timestamp": "2014-10-26T01:34:57+02:00",
            "url": "http://gitlab.local/root/jenkins-hooks-test/commit/23cb86268570fcf53b59870fb7f4bc2fc5bf1f16",
            "author": {
                "name": "Vanja Radovanović",
                "email": "[email protected]"
            }
        },
        {
            "id": "8e71eab5362ef1165b6e233c97f7e9afcdba6485",
            "message": "change\n",
            "timestamp": "2014-10-26T20:11:21+01:00",
            "url": "http://gitlab.local/root/jenkins-hooks-test/commit/8e71eab5362ef1165b6e233c97f7e9afcdba6485",
            "author": {
                "name": "Vanja Radovanović",
                "email": "[email protected]"
            }
        },
        {
            "id": "2edb684defde57dce8344ed5800b5e90e4e18a5d",
            "message": "Merge branch 'develop' into 'master'\nMerge test\nSee merge request !1\n",
            "timestamp": "2014-10-26T12:32:00-07:00",
            "url": "http://gitlab.local/root/jenkins-hooks-test/commit/2edb684defde57dce8344ed5800b5e90e4e18a5d",
            "author": {
                "name": "Administrator",
                "email": "[email protected]"
            }
        }
    ],
    "total_commits_count": 3
}

The way I see it, everything has been done normally. I know that Gitlab offers the ability to push data on the hook url when merge request is at hand, but I fail to see the reason you would need that.

Maybe if you can offer a bit more details on your flow?