Gitlab and Jenkins integration : The objective of GitLab and Jenkins integration is to allow us to trigger a Jenkins build when ( jenkins gitlab webhook ) :

  • A code is pushed to a repository
  • A merge request is created.

In this tutorial , we will try to integrate GitLab and Jenkins.

GitLab Configuration

Create build user and access token at Gitlab

To create a user and access token go to

Profile Settings >>> Access Tokens.

Over there create a new user named “jenkins-user” then we have to create a personal access token and save.

Now you have to copy the access token and save somewhere, because it is visible only one time , so its very important to save it !!

Jenkins Configuration

Add Gitlab credentials to Jenkins

Now we will add a new credential of the type GitLab API token In the Jenkins’s System credentials. Paste the API token copied earlier in the ‘API Token’ field and save them.

Configure Jenkins server

To start configuring the Jenkins server we have to install :

To configure the Jenkins server go to :

Manage Jenkins >>> Configure System

In the ‘GitLab’ section :

  1. set the GitLab server URL in the GitLab host URL field
  2. select the added Gitlab credentials from the credentials drop-drown.

Configure Jenkins project

After configuring connection between Jenkins and GitLab. now we have to create a job. For configuring a Jenkins project , try to follow the next steps :

[1]

After inserting the GitLab connection we will setup the git repository

[2]

Now we will try to choose the event that start the pipeline (example push events)

[3]
[4]

Webhook Configuration using Gitlab

Now we will create GitLab project or choose an existing one. Then :

Project >>> Integrations >>> Jenkins CI.

  1. Enter the Jenkins project URL in the given ‘URL’ field
  2. select the trigger events from the list and save, as a result, a new web hook will be added accordingly
[1]
[2]

Here we picked the Push events, Now If you push a commit to the repository of the project ,Jenkins job start running !! for code quality , try to read this tutorial : Example of SonarQube with Jenkins using Docker Images


gitlab jenkins integration , integrate gitlab with jenkins , gitlab api token jenkins , gitlab integration with jenkins , gitlab jenkins webhook , jenkins gitlab connection , jenkins gitlab webhook , jenkins gitlab , gitlab jenkins , jenkins gitlab integration tutorial

Commentaires

  1. Pingback: Example of SonarQube with Jenkins using Docker Images » JavaTuto

  2. Pingback: (Solved) : Jenkins the input device is not a TTY !!

  3. Pingback: (SOLVED) Updates were rejected because the tag already exists !!

Laisser un commentaire