This page looks best with JavaScript enabled

How to connect Jenkins with GitLab and Docker

 ·  ☕ 3 min read  ·  🐧 sysadmin

In this series I explain how to install Jenkins, GitLab and Docker on three separate virtual machines in Proxmox and connect them together to run the job in Jenkins, that is using Jenkins pipeline located at GitLab server and run a docker container from predefined configuration in a docker file to perform a test. Scroll down to read the tutorial, please.

Intro:

Part one:

Part two:

Tutorial

Add Jenkins repository
SLES | openSUSE Leap 15.4
1
2
sudo zypper addrepo http://pkg.jenkins.io/opensuse-stable/ jenkins
sudo zypper ref
Debian
1
2
3
4
wget https://pkg.jenkins.io/debian-stable/jenkins.io.key
sudo apt-key add jenkins.io.key
echo "deb https://pkg.jenkins.io/debian-stable binary/" | tee /etc/apt/sources.list.d/jenkins.list
sudo apt update -y
Red Hat
1
2
3
sudo dnf install wget
wget -O /etc/yum.repos.d/jenkins.repo http://pkg.jenkins-ci.org/redhat-stable/jenkins.repo
sudo rpm --import https://pkg.jenkins.io/redhat-stable/jenkins.io.key
Install Java 11 open JDK
SLES | openSUSE Leap 15.4
1
sudo zypper install java-11-openjdk
Debian
1
sudo apt install openjdk-11-jdk
Red Hat
1
sudo dnf install java-11-openjdk
Check Java version
1
java -version
Install Jenkins
SLES | openSUSE Leap 15.4
1
sudo zypper install jenkins
Debian
1
sudo apt install jenkins
Red Hat
1
sudo dnf install jenkins
Enable and start Jenkins
1
2
sudo systemctl enable jenkins
sudo systemctl start jenkins

If you will see the error about missing file or directory during enabling the Jenkins, you have to edit the file /usr/lib/systemd/systemd-sysv-install and change the line that contains S50 and change the line to the below one:

symlink="$(pwd)/$1"

After that enable and start Jenkins once again.

Add port 8080 in firewalld, reload the configuration and check the firewall configuration status
1
2
3
sudo firewall-cmd --add-port=8080/tcp --permanent --zone="public"
sudo firewall-cmd --reload
sudo firewall-cmd --list-all
Check the IP address of your machine
1
hostname -I
Copy the URL and paste it into the address bar in your browser and continue the installation
Display and copy the password from the file and paste it into the admin’s password field. Use combination ctrl+shift+c to copy the displayed password from the command line.
1
sudo cat /var/lib/jenkins/secrets/initialAdminPassword
Install suggested plugins and continue
Create first administrator and continue.
Leave Jenkins URL as it is.
Install locale plugin

Go to Manage Jenkins, then click Plugins, click available plugins, in search field type locale and hit Enter. Click on the button install without restart. Then click one more time on Manage Jenkins, Click System and scroll down to locale section. Set en_us language in Default language field and select Ignore browser preference and force this language to all users. Click Apply and Save buttons. Install the Restart plugin the same way and restart Jenkins.

Remove initial admin’s password.
1
sudo rm -f /var/lib/jenkins/secrets/initialAdminPassword
Summarize

Using above method you have working Jenkins that you can later connect with GitLab and Docker servers to create environment for testing purpose.

Share on

sysadmin
WRITTEN BY
sysadmin
QA & Linux Specialist