How to install Jenkins on Ubuntu 22.04
To Install Jenkins On Ubuntu 22.04
Introduction:
Jenkins is a continuous integration (CI) server that supports a wide range of tools and technologies. Adopting a CI process ensures that all developers' working copies of code are regularly merged into a shared trunk. Once a change is committed to the repository, the product is automatically rebuilt and tested.
Procedure:
Step – 1 : At first, Check the OS version
root@linuxhelp:~# lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description: Ubuntu 22.04.3 LTS
Release: 22.04
Codename: jammy
Step – 2 : Now download package repository of Jenkins to automate installation by using the wget command
root@linuxhelp:~# wget -O /usr/share/keyrings/jenkins-keyring.asc https://pkg.jenkins.io/debian-stable/jenkins.io-2023.key
--2023-10-26 14:50:50-- https://pkg.jenkins.io/debian-stable/jenkins.io-2023.key
Resolving pkg.jenkins.io (pkg.jenkins.io)... 151.101.2.133, 151.101.66.133, 151.101.130.133, ...
Connecting to pkg.jenkins.io (pkg.jenkins.io)|151.101.2.133|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 3175 (3.1K) [application/pgp-keys]
Saving to: ‘/usr/share/keyrings/jenkins-keyring.asc’
/usr/share/keyrings/jenkins-keyr 100%[==========================================================>] 3.10K --.-KB/s in 0s
2023-10-26 14:50:51 (21.4 MB/s) - ‘/usr/share/keyrings/jenkins-keyring.asc’ saved [3175/3175]
Step – 3 : Add a Jenkins apt repository entry by using the following command
root@linuxhelp:~# echo deb [signed-by=/usr/share/keyrings/jenkins-keyring.asc] https://pkg.jenkins.io/debian-stable binary/ | sudo tee /etc/apt/sources.list.d/jenkins.list > /dev/nul
Step – 4 : Update the repository by using the following command
root@linuxhelp:~# apt update
Ign:1 https://pkg.jenkins.io/debian-stable binary/ InRelease
Get:2 https://pkg.jenkins.io/debian-stable binary/ Release [2,044 B]
Hit:3 http://in.archive.ubuntu.com/ubuntu jammy InRelease
Get:4 https://pkg.jenkins.io/debian-stable binary/ Release.gpg [833 B]
Get:5 http://in.archive.ubuntu.com/ubuntu jammy-updates InRelease [119 kB]
Get:6 https://pkg.jenkins.io/debian-stable binary/ Packages [25.8 kB]
Get:7 http://in.archive.ubuntu.com/ubuntu jammy-backports InRelease [109 kB]
Get:8 http://in.archive.ubuntu.com/ubuntu jammy-updates/main amd64 Packages [1,103 kB]
Get:9 http://in.archive.ubuntu.com/ubuntu jammy-updates/main i386 Packages [515 kB]
Get:10 http://in.archive.ubuntu.com/ubuntu jammy-updates/main Translation-en [239 kB]
Get:11 http://in.archive.ubuntu.com/ubuntu jammy-updates/main amd64 DEP-11 Metadata [101 kB]
Get:12 http://in.archive.ubuntu.com/ubuntu jammy-updates/main amd64 c-n-f Metadata [16.0 kB]
Get:13 http://in.archive.ubuntu.com/ubuntu jammy-updates/restricted i386 Packages [32.4 kB]
Get:14 http://in.archive.ubuntu.com/ubuntu jammy-updates/restricted amd64 Packages [1,036 kB]
Fetched 11.0 MB in 10s (1,137 kB/s)
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
99 packages can be upgraded. Run 'apt list --upgradable' to see them.
Step – 5 : Now install the Jenkins dependencies by using the following command
root@linuxhelp:~# apt install fontconfig openjdk-11-jre
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
fontconfig is already the newest version (2.13.1-4.2ubuntu5).
fontconfig set to manually installed.
The following packages were automatically installed and are no longer required:
libflashrom1 libftdi1-2 libllvm13
Use 'apt autoremove' to remove them.
The following additional packages will be installed:
ca-certificates-java fonts-dejavu-extra java-common libatk-wrapper-java libatk-wrapper-java-jni openjdk-11-jre-headless
Suggested packages:
default-jre fonts-ipafont-gothic fonts-ipafont-mincho fonts-wqy-microhei | fonts-wqy-zenhei
The following NEW packages will be installed:
ca-certificates-java fonts-dejavu-extra java-common libatk-wrapper-java libatk-wrapper-java-jni openjdk-11-jre
openjdk-11-jre-headless
0 upgraded, 7 newly installed, 0 to remove and 99 not upgraded.
Need to get 44.9 MB of archives.
After this operation, 184 MB of additional disk space will be used.
Do you want to continue? [Y/n] y
Get:1 http://in.archive.ubuntu.com/ubuntu jammy/main amd64 java-common all 0.72build2 [6,782 B]
Get:2 http://in.archive.ubuntu.com/ubuntu jammy-updates/main amd64 openjdk-11-jre-headless amd64 11.0.20.1+1-0ubuntu1~22.04 [42.5 MB]
Get:3 http://in.archive.ubuntu.com/ubuntu jammy-updates/main amd64 ca-certificates-java all 20190909ubuntu1.2 [12.1 kB]
Updating certificates in /etc/ssl/certs...
0 added, 0 removed; done.
Running hooks in /etc/ca-certificates/update.d...
done.
done.
Step – 6 : Install the Jenkins by using the apt command with –y option
root@linuxhelp:~# apt install jenkins -y
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
The following packages were automatically installed and are no longer required:
libflashrom1 libftdi1-2 libllvm13
Use 'apt autoremove' to remove them.
The following additional packages will be installed:
net-tools
The following NEW packages will be installed:
jenkins net-tools
0 upgraded, 2 newly installed, 0 to remove and 99 not upgraded.
Need to get 89.1 MB of archives.
After this operation, 90.4 MB of additional disk space will be used.
Get:2 http://in.archive.ubuntu.com/ubuntu jammy/main amd64 net-tools amd64 1.60+git20181103.0eebece-1ubuntu5 [204 kB]
Get:1 https://pkg.jenkins.io/debian-stable binary/ jenkins 2.414.3 [88.9 MB]
Fetched 89.1 MB in 16s (5,709 kB/s)
Selecting previously unselected package net-tools.
(Reading database ... 202547 files and directories currently installed.)
Preparing to unpack .../net-tools_1.60+git20181103.0eebece-1ubuntu5_amd64.deb ...
Unpacking net-tools (1.60+git20181103.0eebece-1ubuntu5) ...
Selecting previously unselected package jenkins.
Preparing to unpack .../jenkins_2.414.3_all.deb ...
Unpacking jenkins (2.414.3) ...
Setting up net-tools (1.60+git20181103.0eebece-1ubuntu5) ...
Setting up jenkins (2.414.3) ...
Created symlink /etc/systemd/system/multi-user.target.wants/jenkins.service → /lib/systemd/system/jenkins.service.
Processing triggers for man-db (2.10.2-1) ...
Step – 7 : After the installation start the Jenkins service by using the following command
root@linuxhelp:~# systemctl start jenkins
Step – 8 : Check the status of the Jenkins service by using the following command
root@linuxhelp:~# systemctl status jenkins
● jenkins.service - Jenkins Continuous Integration Server
Loaded: loaded (/lib/systemd/system/jenkins.service; enabled; vendor preset: enabled)
Active: active (running) since Thu 2023-10-26 14:56:48 IST; 1min 37s ago
Main PID: 8874 (java)
Tasks: 47 (limit: 4556)
Memory: 1.1G
CPU: 2min 3.384s
CGroup: /system.slice/jenkins.service
└─8874 /usr/bin/java -Djava.awt.headless=true -jar /usr/share/java/jenkins.war --webroot=/var/cache/jenkins/war --http>
Oct 26 14:56:13 linuxhelp jenkins[8874]: c06931140838478aaaac944cd55bb49d
Oct 26 14:56:13 linuxhelp jenkins[8874]: This may also be found at: /var/lib/jenkins/secrets/initialAdminPassword
Oct 26 14:56:13 linuxhelp jenkins[8874]: *************************************************************
Oct 26 14:56:13 linuxhelp jenkins[8874]: *************************************************************
Oct 26 14:56:13 linuxhelp jenkins[8874]: *************************************************************
Oct 26 14:56:48 linuxhelp jenkins[8874]: 2023-10-26 09:26:48.754+0000 [id=36] INFO jenkins.InitReactorRunner$1#onAtta>
Oct 26 14:56:48 linuxhelp jenkins[8874]: 2023-10-26 09:26:48.790+0000 [id=23] INFO hudson.lifecycle.Lifecycle#onReady>
Oct 26 14:56:48 linuxhelp systemd[1]: Started Jenkins Continuous Integration Server.
Oct 26 14:56:49 linuxhelp jenkins[8874]: 2023-10-26 09:26:49.805+0000 [id=51] INFO h.m.DownloadService$Downloadable#l>
Oct 26 14:56:49 linuxhelp jenkins[8874]: 2023-10-26 09:26:49.810+0000 [id=51] INFO hudson.util.Retrier#start: Perform>
Step – 9 : Now allow the default Jenkins port 8080 in Ubuntu default firewall
root@linuxhelp:~# ufw allow 8080
Rules updated
Rules updated (v6)
Step – 10 : Also allow the OpenSSH in Ubuntu default firewall
root@linuxhelp:~# ufw allow OpenSSH
Rules updated
Rules updated (v6)
Step – 11 : Now enable the Ubuntu default firewall by using the following command
root@linuxhelp:~# ufw enable
Firewall is active and enabled on system startup
Step – 12 : Now check the status of the firewall by using the following command
root@linuxhelp:~# ufw status
Status: active
To Action From
-- ------ ----
8080 ALLOW Anywhere
OpenSSH ALLOW Anywhere
8080 (v6) ALLOW Anywhere (v6)
OpenSSH (v6) ALLOW Anywhere (v6)
Now go to the browser and search with you ip or domain along with port number
root@linuxhelp:~# cat /var/lib/jenkins/secrets/initialAdminPassword
c06931140838478aaaac944cd55bb49d
Enter the password and click continue button
Conclusion:
We have reached the end of this article. In this guide, we have walked you through the steps required to install Jenkins on Ubuntu 22.04. Your feedback is much welcome.
A working build script, e.g., a Maven script, checked into the repository