In this tutorial, we are going to look at how to install Jenkins on Ubuntu 20.04. First, let us learn what Jenkins is and what it is used for. So What is Jenkins?

Ever heard of build management systems? These are automation servers used by developers to build test and deploy their software in order to ensure continuous integration and continuous delivery. Jenkins is one of those servers and it is purely open source. When several developers are working on a software, the codes could first be pushed to a version control system such as Github and then passed to a build management system such as Jenkins where the codes are build to an application, tested and released or made available for users to download and use. Note that Docker is supported by majority of build management systems including Jenkins.

You will mostly hear Jenkins being used by DevOps Engineers together with other terms such as CI (Continuous Integration) and CD (Continuous Delivery/ Deployment). Jenkins is built with plugins that ensure continuous integration processes. It helps developers to automate the process of building and testing codes, enabling them to easily make or incorporate changes where needed thus also ensuring continuous delivery of the end product to the end user. Having understood what Jenkins is and what it is used for, let us now proceed to look at how to install Jenkins Server on Ubuntu 20.04.

Install Jenkins Server on Ubuntu 20.04

The following steps describe how to install and configure Jenkins on Ubuntu 20.04.

Step 1: Install Java

Jenkins is a Java application and we need to ensure that the latest version of Java is installed in our systems. Java 8 or later is required.

You can check the Java version installed by running the below command:

$ java –version
Command 'java' not found, but can be installed with:

As you can see, I do not have Java installed and I am going to install with the below command:

sudo apt update
sudo apt install default-jdk

Once installed, confirm the version

$ java --version
openjdk 11.0.9.1 2020-11-04
OpenJDK Runtime Environment (build 11.0.9.1+1-Ubuntu-0ubuntu1.20.04)
OpenJDK 64-Bit Server VM (build 11.0.9.1+1-Ubuntu-0ubuntu1.20.04, mixed mode, sharing)

Step 2: Install Jenkins Server on Ubuntu 20.04

We are going to be installing Jenkins from its official repository. First import Jenkins GPG key

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

Next, add Jenkins repository to your system with the below command:

sudo sh -c 'echo deb http://pkg.jenkins.io/debian-stable binary/ > /etc/apt/sources.list.d/jenkins.list'

Then update system packages

sudo apt update

Now install Jenkins with the below command:

sudo apt install jenkins

Jenkins is set to start automatically after installation. When the installation process is complete, confirm Jenkins status

$ sudo systemctl status jenkins
● jenkins.service - LSB: Start Jenkins at boot time
     Loaded: loaded (/etc/init.d/jenkins; generated)
     Active: active (exited) since Thu 2021-02-04 23:13:05 EAT; 1min 21s ago
       Docs: man:systemd-sysv-generator(8)

Step 3: Configure firewall

If you are running an active firewall, you need to open port 8080 which Jenkins natively run on

sudo ufw allow 8080/tcp
sudo ufw reload

Step 4: Configure Jenkins Server from the browser

Open Jenkins web interface using your server IP address and port 8080; http://<server-ip>:8080. This is the first page you get:

Get the password from the provided file. In this case, /var/lib/jenkins/secrets/initialAdminPassword. You can easily retrieve the password by running the below command on the Jenkins server terminal:

cat /var/lib/jenkins/secrets/initialAdminPassword

Paste the password and click ‘Continue’. You get a page similar to the below. Here, select suggested plugins if you are new to Jenkins for simplicity purposes.

This will begin installation of the necessary plugins as below:

Once plugins installations are done,you will be prompted to create an admin user

Enter the details required and at the bottom right of the page, click ‘save and Continue’. The next page shows the default url for your Jenkins installation. You don’t have to do anything here. Simply click ‘Save and Finish’ at the bottom right of the page.

Your Jenkins is ready. Click on ‘Start Using Jenkins

Below is Jenkins dashboard

If you are aspiring to become a DevOps Engineer, Jenkins is one the tools you definitely need to learn about. Continuous integration makes delivery fast and easy to reduces the back and forth between the developers, operators and the clients and therefore ensures a happy client.

We hope the guide has been useful in installing Jenkins on Ubuntu 20.04. Do not forget to check out more of our interesting Linux guides below:

LEAVE A REPLY

Please enter your comment!
Please enter your name here