Installing Jenkins on Ubuntu 22.04

Jenkins cannot run without Java so install the Java JDK.

sudo apt-get install openjdk-11-jdk -y

Obtain the Jenkins GPG key.

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

Add the Jenkins repository to Ubuntu.

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

Update system packages and install Jenkins.

sudo apt update; sudo apt install jenkins -y

Start the Jenkins service.

sudo systemctl start jenkins.service

Confirm that the Jenkins service is enabled and running.

sudo systemctl status jenkins.service

Configure the firewall to allow traffic from port 8080.

sudo ufw allow 8080

You will see something like this:

Access localhost:8080 on your browser. You will see the Getting Started page with instructions on how to retrieve the initial password in order to access the Jenkins dashboard.

Output the contents of the file specified by the Jenkins Getting Started page.

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

You will get a string of letters and numbers. Copy the password and paste it into the input field on the Jenkins Getting Started page, and click Continue.

Next, you will be asked whether you want to install suggested plugins or manually select the plugins that you need. It is recommended to go with the first option.

Wait for Jenkins to finish installing the plugins.

Provide your details in order to create your own admin user.

Next, you will be asked to configure the URL of your Jenkins server. It is recommended to use the default address of localhost:8080 although you can set it to any IP address and port you like. Just make sure to make the necessary configurations.

Once everything is set up, you can now log into your Jenkins dashboard.

Want to get started on a simple Jenkins pipeline? Click here.