04 – GitLab and Jenkins integration via Webhooks and GitLab plugin

There are many ways that lead to the goal in IT world. You have to choose the right for your purposes.

In previous post I showed you the most common way to integrate any git repository with Jenkins – I mean SCM Polling. This time I’ll show you an another (GitLab specific) method that opens the door to do Jenkins and GitLab advanced integration such: team collaboration, pull requests, separate branch builting/testing and notifications.

High-level process overview

The previous process looks like below:

Developer performs push to GitLab repository <= Jenkins scans the target repository for chenges every 2 minutes => If change was detected, jenkins builds the project.

This time the process is a little different:

Developer performs push to GitLab repository => GitLab sends a notification to Jenkins => Jenkins builds the project.

With this approach you can integrate Jenkins and GitLab much more, or for different purposes.

Requirements

 Preparation

After previous steps you should have GitLab and Jenkins projects configured as below:

a4d7_001

18b9_001

J04-basic-build Config [Jenkins]

Test your job

Building master branch

Clone the J04-gitlab-integration repository and make some change.

Open jenkins console. Push to remote repository should trigger a new job instance, but it was failed because “No such file or directory” error.

be0b_001

It’s ok – let’s fix it now by adding some text file with even number of words:

Both steps (build and test) should be successfully completed:

dc1a_001

Building custom branch

Previous solution works albo with branches.

As you can see the build started and test-branch was checked out.

b566_001

What’s next

In the next part I will show you how to integrate Jenkins and GitLab to work with branches (better way) and pull requests.

Facebooktwittergoogle_plusredditlinkedinmail

Leave a Reply

Be the First to Comment!

Notify of
avatar
wpDiscuz