How to install Jenkins on Ubuntu

Endrit Qerreti

Endrit Qerreti

In this tutorial, you will learn how to install Jenkins on Ubuntu.

Jenkins is an open source automation software that allows you to automate your continuous integration and delivery tasks.

Jenkins is written in Java, and it's a very useful tool when it comes to building, testing and deploying software.

Install Jenkins on Ubuntu

Step 1 - Add Jenkins Key

Before we begin with the installation process, first we must download Jenkins key on our server, this is necessary so that we can install Jenkins.

To add Jenkins key we can use a package like wget

sudo wget -O /usr/share/keyrings/jenkins-keyring.asc https://pkg.jenkins.io/debian-stable/jenkins.io-2023.key

Step 2 - Setup Jenkins Repository

By default Jenkins can not be downloaded from the terminal because there's no jenkins package on official repositories of Ubuntu. To be able to Download Jenkins on Ubuntu, you need to add its repository on your system.

To do so, simply run the command below

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

Now you should be able to use this repository, and move to the next step to continue installing Jenkins

Step 3 - Update your machine

Now that you added Jenkins repository on your machine, proceed to update your machine so that Jenkins repository can be used.

To update your machine, run the command below. Once you check for updates, you will notice Jenkins repository showing as "HIT" on the output on your terminal. This means Jenkins repository is now ready to be used for downloading Jenkins.

sudo apt update

Step 4 - Install Jenkins

Once you added key, set up Jenkins repository and updated your machine, now you are good to go and install Jenkins from the terminal.

To install Jenkins, simply run the command below

sudo apt install jenkins -y

Step 5 - Setup Jenkins

Once you have installed Jenkins on your machine, Jenkins will start automatically on port 8080.

To set up Jenkins, launch your browser and navigate to http://127.0.0.1:8080 and create the admin account that you will be using to manage your Jenkins server.

Uninstall Jenkins

To uninstall Jenkins, you can use the default package manager on Ubuntu

sudo apt purge jenkins

Conclusion

In this tutorial, you learned how to install Jenkins on Ubuntu by setting up the official Jenkins repository.