How To Install Jenkins Server on Ubuntu 20.04|18.04

Posted on 132 views

Hello good people. In this article, we’ll have a look at how to install Jenkins Server on Ubuntu 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 20.04/18.04 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 20.04/18.04 is from apt repository. With APT repository installation method the package can be upgraded with the system upgrades.

Install Jenkins Server on Ubuntu 20.04|18.04 – Prerequisites:

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

Steps to Install Jenkins Server on Ubuntu 20.04|18.04

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.

sudo systemctl reboot

Add Jenkins repository to Ubuntu 20.04|18.04

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

wget -q -O - https://pkg.jenkins.io/debian-stable/jenkins.io.key | sudo apt-key add -

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.

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 version 8 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 20.04/18.04:

$ 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

Configure Firewall

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)

Configuring Jenkins on Ubuntu 20.04|18.04

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.

install-jenkins-ubuntu-18.04-01

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.

install-jenkins-ubuntu-18.04-02

The next page is on setting your login user account:

install-jenkins-arch-linux-03

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

install-jenkins-ubuntu-18.04-ready

coffee

Gravatar Image
A systems engineer with excellent skills in systems administration, cloud computing, systems deployment, virtualization, containers, and a certified ethical hacker.