How to Install Jenkins on Ubuntu 22.04 Step-by-Step

The step-by-step guide on this page will show you how to install Jenkins on Ubuntu 22.04.

Jenkins is an open-source automation server widely used for continuous integration and continuous deployment (CI/CD) in software development. With its extensive plugin ecosystem and user-friendly interface, Jenkins simplifies the process of building, testing, and deploying code.

Prerequisites

  • Pre-Installed Ubuntu 22.04
  • User with sudo privileges
  • Internet Connectivity

Without much fuss , let’s deep dive into Jenkins installation steps on Ubuntu 22.04 or 20.04

1) Install Java Development Kit (JDK)

Being a Java application, Jenkins requires Java 8 and later versions to run without any issues. To check if Java is installed on your system, run the command:

$ java --version

If Java is not installed, you will get the following output.

Check-whether-Java-Installled-Ubuntu

To install Java on your system, execute the command:

$ sudo apt install -y openjdk-17-jre-headless

After the installation, once again verify that Java is installed:

$ java --version

Check-Java-Version-Ubuntu

Perfect! We now have OpenJDK installed. We can now proceed.

2) Install Jenkins on Ubuntu 22.04

With Java installed, we can now proceed to install Jenkins. The first step is to import the Jenkins GPG key from Jenkins repository as shown:

$ curl -fsSL https://pkg.jenkins.io/debian-stable/jenkins.io-2023.key | sudo tee \
/usr/share/keyrings/jenkins-keyring.asc > /dev/null

Next, configure Jenkins repository to the sources list file echo and tee command.

$ 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/null

Next, update the system’s package list.

$ sudo apt update

And install Jenkins as follows.

$ sudo apt install -y jenkins

Install-jenkins-apt-command

Once the installation is complete, Jenkins should start automatically. To confirm this, run the command:

$ systemctl status jenkins

Jenkins-Systemctl-Status-Ubuntu

If by any chance Jenkins is not running, execute the following command to start it.

$ sudo systemctl start jenkins

3) Configure Firewall Rules for Jenkins

As we have seen, Jenkins natively listens on port 8080, and if you have installed Jenkins on a server with UFW enabled, you need to open that port to allow traffic.

To enable firewall on Ubuntu 22.04, run

$ sudo ufw enable

To open port 8080 on ufw firewall, run the command:

$ sudo ufw allow 8080/tcp

Then reload the firewall to effect the changes.

$ sudo ufw reload

To confirm that port 8080 is open on the firewall, execute the command:

$ sudo ufw status

Ubuntu-firewall-status-jenkins

From the output, we can clearly see that Port 8080 has been opened on the system.

4) Setup Jenkins with Web Interface

We are almost done now. The only thing remaining is to set up Jenkins using web interface. So, head over to the URL bar and browse your server’s address as shown:

http://server-IP:8080

To check your server’s IP address, use the ip command.

View-IP-Address-Ubuntu-Linux

You will get the page similar to what we have below prompting you to provide the Administrator’s password. As per the instructions, the password is located in the file:

/var/lib/jenkins/secrets/initialAdminPassword

To view the password, use the cat command as shown:

$ sudo cat /var/lib/jenkins/secrets/initialAdminPassword

Copy the password and paste it in the text field shown and click the “Continue” button.

Unlock-Jenkins-Page-Ubuntu-Linux

In the next step, select ‘Install suggested plugin‘ for simplicity’s sake.

Install-suggested-Plugins-Jenkins-Ubuntu

Thereafter, the installation of the necessary plugin required by Jenkins will commence.

jenkins-plugins-installation-progress-ubuntu

When the installation of plugins is complete, the installer will take you to the next section where you will be required to create an Admin user and click on the ‘Save and Continue’ button.

Create-Admin-User-Jenkins-Ubuntu

The next step will populate the default URL for your Jenkin’s instance. No action is required, simply click ‘Save and Finish’.

Jenkins-URL-Instance-Configuration

Finally, click on the ‘Start using Jenkins’ button to gain access to Jenkins.

Start-Using-Jenkins-Page-Ubuntu

This ushers you to Jenkin’s dashboard as shown.

Jenkins-Dashboard-Ubuntu-Linux

Conclusion

In this guide, we’ve outlined the step-by-step process to install Jenkins on Ubuntu 22.04. Jenkins is a powerful tool that can significantly improve your development workflow by automating repetitive tasks and streamlining your CI/CD process. Explore the vast array of plugins and integrations Jenkins offers to customize your automation server according to your project’s requirements.

Also Read : How to Setup Jenkins on CentOS 8 / RHEL 8

5 thoughts on “How to Install Jenkins on Ubuntu 22.04 Step-by-Step”

Leave a Reply to ARSLAN Cancel reply