This page looks best with JavaScript enabled

Connect Jenkins and GitLab

 ·  ☕ 1 min read  ·  🐧 sysadmin

In this video I explain how to connect Jenkins and GitLab.

Tutorial

  1. Go to GitLab website and copy the URL. In my case it is 10.10.0.119

  2. Login via SSH to Jenkins server and copy the certificate from GitLab

1
</dev/null openssl s_client -connect 10.10.0.119:443 -servername 10.10.0.119 | openssl x509 > $HOME/10.10.0.119.crt

sudo find / -iname “cacerts”

5. 
```bash
java -version
1
sudo find / -iname "keytool"
  1. Import GitLab certificate to Java cacerts
1
2
3
4
5
6
7
8
# Import GitLab certificate
sudo /usr/lib64/jvm/java-11-openjdk-11/bin/keytool -import -file /home/adrian/10.10.0.119.crt -alias gitlab -keystore /usr/lib64/jvm/java-11-openjdk-11/lib/security/cacerts

# Delete GitLab certificate
sudo /usr/lib64/jvm/java-11-openjdk-11/bin/keytool -delete -alias gitlab -keystore /usr/lib64/jvm/java-11-openjdk-11/lib/security/cacerts

# List all certificates
sudo /usr/lib64/jvm/java-11-openjdk-11/bin/keytool -list -keystore /usr/lib64/jvm/java-11-openjdk-11/lib/security/cacerts
  1. type password
1
changeit
  1. Trust this certificate? Type:
yes

And hit Enter

  1. Restart Jenkins
1
sudo systemctl restart jenkins.service
  1. Install GitLab plugin in Jenkins and restart Jenkins

  2. Log into the GitLab, create a project and generate a token for project.

  3. Go to Manage Jenkins -> System and scroll down to find GitLab section.

  4. Provide a connection name eg. GitLab, GitLab URL and credentials (use API token generated in GitLab for the project to add credentials - see the video)

  5. Test the connection.

Share on

sysadmin
WRITTEN BY
sysadmin
QA & Linux Specialist