We are committed to provide service 24 X 7

Deals, Shopping, Training, Tools

Learn how to – How To Install Jenkins Server on Ubuntu 22.04|20.04|18.04

Learn how to – How To Install Jenkins Server on Ubuntu 22.04|20.04|18.04.

Hello good people. In this article, we’ll have a look at how to install Jenkins Server on Ubuntu 22.04/20.04/18.04 server. Jenkins is an open source automation server written in Java that was designed to automate repetitive tasks that are often encountered in continuous integration and delivery of software.

For Arch Linux: How to Install and Configure Jenkins on Arch Linux

For CentOS 7: How to install Jenkins Server Stable on CentOS 7

For Docker Container: Running Jenkins Server in Docker Container with Systemd

Installation of Jenkins on Ubuntu system can be done from Ubuntu packages or by downloading and running its Web application Archive (WAR) file. The most preferred method of installing Jenkins on Ubuntu is from apt repository. With APT repository installation method the package can be upgraded with the system upgrades.

Install Jenkins Server on Ubuntu 22.04|20.04|18.04

  • Minimum of 1GB of memory
  • Update Ubuntu system
  • A Linux user with sudo privileges

Step 1 – Update System

Let’s start the installation of by doing a system update and upgrade:

$ sudo apt update
Get:1 http://security.ubuntu.com/ubuntu bionic-security InRelease [83.2 kB]
Hit:2 http://mirrors.digitalocean.com/ubuntu bionic InRelease 
Get:3 http://mirrors.digitalocean.com/ubuntu bionic-updates InRelease [83.2 kB]
Get:4 http://mirrors.digitalocean.com/ubuntu bionic-backports InRelease [74.6 kB]
Get:5 http://mirrors.digitalocean.com/ubuntu bionic-updates/main amd64 Packages [119 kB]
Get:6 http://mirrors.digitalocean.com/ubuntu bionic-updates/universe amd64 Packages [79.8 kB]
Fetched 440 kB in 2s (224 kB/s)
Reading package lists... Done

$ sudo apt upgrade -y

You may need to reboot your system before you can proceed since system upgrade may update the kernel.

 [ -f /var/run/reboot-required ] && sudo reboot -f

Step 2 – Add Jenkins repository

The version of Jenkins available on Ubuntu is older than the upstream version, we’ll use the project-maintained packages to install Jenkins. Add repository key using the command:

curl -fsSL  https://pkg.jenkins.io/debian-stable/jenkins.io.key | sudo gpg --dearmor -o /etc/apt/trusted.gpg.d/jenkins.gpg

Once the key has been added, We need to add Jenkins stable Debian package repository:

echo "deb https://pkg.jenkins.io/debian-stable binary/" | sudo tee /etc/apt/sources.list.d/jenkins.list

Then update the apt packages index:

$ sudo apt update
Get:1 http://mirrors.digitalocean.com/ubuntu focal InRelease [265 kB]
Hit:2 http://mirrors.digitalocean.com/ubuntu focal-updates InRelease
Ign:3 https://pkg.jenkins.io/debian-stable binary/ InRelease
Hit:4 http://mirrors.digitalocean.com/ubuntu focal-backports InRelease
Get:5 https://pkg.jenkins.io/debian-stable binary/ Release [2044 B]
Get:6 https://pkg.jenkins.io/debian-stable binary/ Release.gpg [833 B]
Hit:7 http://security.ubuntu.com/ubuntu focal-security InRelease
Get:8 https://pkg.jenkins.io/debian-stable binary/ Packages [20.2 kB]
Fetched 288 kB in 1s (458 kB/s)
Reading package lists... Done
Building dependency tree
Reading state information... Done
All packages are up to date.

Step 3 – Install Jenkins Server

Once this is done, install Java JDK using below commands:

sudo apt install default-jdk

If you have more than one version of Java JDK installed, you can select another version as default using the command:

$ sudo update-alternatives --config java
There is only one alternative in link group java (providing /usr/bin/java): /usr/lib/jvm/java-11-openjdk-amd64/bin/java
Nothing to configure.

Then install Jenkins Server on Ubuntu.

$ sudo apt install jenkins
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following additional packages will be installed:
  daemon net-tools
The following NEW packages will be installed:
  daemon jenkins net-tools
0 upgraded, 3 newly installed, 0 to remove and 0 not upgraded.
Need to get 71.9 MB of archives.
After this operation, 75.4 MB of additional disk space will be used.
Do you want to continue? [Y/n] y

Step 4 – Configure Firewall (optional)

If you happen to be using ufw firewall for Ubuntu, open port 8080 on the firewall

$ sudo  ufw enable
Command may disrupt existing ssh connections. Proceed with operation (y|n)? y
Firewall is active and enabled on system startup

$ sudo ufw allow 8080
Rule added
Rule added (v6)

$ sudo ufw status
Status: active

To                         Action      From
--                         ------      ----
8080                       ALLOW       Anywhere                  
8080 (v6)                  ALLOW       Anywhere (v6)             

$ sudo ufw allow ssh
Rule added
Rule added (v6)

$ sudo ufw status
Status: active

To                         Action      From
--                         ------      ----
8080                       ALLOW       Anywhere                  
22/tcp                     ALLOW       Anywhere                  
8080 (v6)                  ALLOW       Anywhere (v6)             
22/tcp (v6)                ALLOW       Anywhere (v6)

Step 5 – Configuring Jenkins

To set up Jenkins installation, visit port  8080 on your server address – domain or IP Address.

http://ip_address_or_domain_name:8080

The first screen will show the “Unlock Jenkins” message. This indicates the location of the initial password.

Copy Password file:

# cat /var/lib/jenkins/secrets/initialAdminPassword
0beb2d7b9bff41079271b5596be431f9

Enter the password on Administrator Password box and click continue. The next page will ask you to install recommended plugins or plugins that suit your desired Jenkins usage. if not sure, select installation of recommended plugins.

The next page is on setting your login user account:

FInish and log in to Jenkins Dashboard to start administering it.

More articles to read on Jenkins:

Cart

Your Cart is Empty

Back To Shop