Skip to main content
Installation

Install Jenkins on Ubuntu

Learn how to install Jenkins on Ubuntu with our step-by-step guide. Automate your software development process and streamline your workflow today.

Sagar Sharma

Jenkins is an open-source automation tool and is quite popular for its seamless integration features.

Written in Java, it comes with hundreds of plugins and the installation process is quite simple.

But before you jump to the installation, here are some prerequisites for this guide:

How to install Jenkins in Ubuntu

There are two variants of Jenkins:

  • LTS (Long Term Release): Updated every 12 weeks
  • Weekly release: Updated on the weekly basis

In this guide, I will show you both ways to choose what fits the best for your workflow.

So let's start with the installation of LTS.

For the LTS version of Jenkins

So if you want to have the LTS release of the Jenkins, all you have to do is execute one single command and it will take care of adding keyrings and repo to the source file:

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

Once done, update the repositories and install the Jenkins using the following:

sudo apt update && sudo apt install jenkins 

For the weekly release of Jenkins

So if you prefer to have the most recent version of Jenkins, use the following command and it will add the repository and keys to your system:

curl -fsSL https://pkg.jenkins.io/debian/jenkins.io-2023.key | sudo tee \
  /usr/share/keyrings/jenkins-keyring.asc > /dev/null
echo deb [signed-by=/usr/share/keyrings/jenkins-keyring.asc] \
  https://pkg.jenkins.io/debian binary/ | sudo tee \
  /etc/apt/sources.list.d/jenkins.list > /dev/null

Now, use the following command to update repositories and install Jenkins:

sudo apt update && sudo apt install jenkins 

And that's it! The installation is complete.

Configure Jenkins on Ubuntu

In this section, I will walk you through the following:

  • Allow Jenkins to pass through the firewall
  • Initial configuration for Jenkins

So let's start with the firewall part.

Allow Jenkins to pass through the Firewall in Ubuntu

So if you're using the firewall (which you must), it won't allow Jenkins to pass through the firewall.

And you can simply change this behavior by adding a rule to allow the port through the UFW firewall.

By default, Jenkins uses port no 8080 so let's add a rule to allow port no 8080 in UFW:

sudo ufw allow 8080

Now, you can check the status of the firewall and it will list all the rules:

sudo ufw status
Allow Jenkins to pass through the Firewall in Ubuntu

If you see UFW Status Inactive, it means that

Initial setup of Jenkins in Ubuntu

By the time of the installation, Jenkins sets a strong admin password and it will be asked on the first step of the configuration.

So how do you know that password? Simple.

It is stored inside /var/lib/jenkins/secrets/initialAdminPassword.

So you can use the cat command to print the file contents:

cat /var/lib/jenkins/secrets/initialAdminPassword
find the admin password configured by Jenkins itself while installation

Once you have the password, you can open Jenkins in your browser using:

http://your_server_ip:8080

And here, you'd have to enter the admin password:

enter admin password to start the jenkins in ubuntu

Next, it will as you to select the plugins. If you are just getting started, choose the first option Install suggested plugins and soon, it will start the installation:

Install seelcted plugins in jenkins

Next, it will ask you to create your first admin user. If you want, you can skip this step but I'll be creating one for my setup:

create an admin user in Jenkins

And in the final step, it will ask you to enter the instance address for the Jenkins which can be the domain or the IP of a server:

enter instance address for Jenkins installation

That's it! Now, you can access the Jenkins dashboard to accomplish desired tasks:

Jenkins daskboard after installation in Ubuntu

And here you have Jenkins installed on your Ubuntu machine.

Want to install Apache Tomcat? Here you go

Using Tomcat is one of the most efficient ways to deploy a Java application.

So how do you install it? Well, we have a dedicated guide for that purpose:

Install Apache Tomcat 9 on Ubuntu
Learn how to properly install Apache Tomcat on Ubuntu Linux.

I hope you will find this guide helpful.

And if you have any queries or suggestions, feel free to ask in the comments.

Sagar Sharma