Configuring gitlab to trigger jenkins build

Configuring gitlab to trigger jenkins build

28 January 2014

We recently integrated gitlab into our workflow. The idea is to use gitlab to manage our development iterations and use merge requests to encourage a code review/verification step. This means that issues will not make it into the iteration unless it's been reviewed and verified.
Once the iteration is complete it will be merged into the mainline repository.

My original reason for using Gitlab and Merge Requests was to stop polluting the repository with incomplete and erroneous commits which caused an iteration to stay open.
Merge requests would allow for cleaner organisation of iterations allowing the team to move incomplete work into the next iteration.

Install Jenkins Gitlab plugin

You will need to install the Jenkins Gitlab Plugin.

Configure job parameters

Gitlab will actually post a parameter called BRANCH_TO_BUILD containing your branch name.
This allows you to have one jenkins job to build all branches for a repository.

Gitlab Parameters

Configure Source Code Management

Configure your job with the git repository information. I have used $BRANCH_TO_BUILD variable in the Branch Specifier field.

Gitlab SCM

Configure Gitlab project with web hook

The Url for the webhook is http://{JENKINS-SERVER}/gitlab/buildnow

Gitlab Hook

Whenever a push to made to gitlab a job will be queued in Jenkins.

Misc

I raised the following feature enhancement:

When I code review an issue I would like to forfeit my responsibility of performing the actual merge and checking the build. I am interested in seeing if code matches our existing conventions, that there is adequate test coverage and the implementations address the requirements. When I have completed the review I would like to assign the issue to the jenkins user.

The gitlab merge request plugin will find and build open merge requests assigned to the jenkins gitlab user. When a build is successful the jenkins user will automatically accept the merge request.

See Automatically merge if build successful and assigned to jenkins user

CI Gitlab Jenkins-CI Tools