Install and Configure Jenkins on Ubuntu 22.04

In this guide, you will learn to Install and Configure Jenkins on Ubuntu 22.04.

Jenkins is a Java-based open-source automation platform with plugins designed for continuous integration. It is used to continually create and test software projects, making it easier for developers and DevOps engineers to integrate changes to the project and for consumers to get a new build. It also enables you to release your software continuously by interacting with various testing and deployment methods. 

Organizations may use Jenkins to automate and speed up the software development process. Jenkins incorporates a variety of development life-cycle operations, such as build, document, test, package, stage, deploy, static analysis, and more. 

Steps To Install and Configure Jenkins on Ubuntu 22.04

To set up Jenkins, log in to your server as a non-root user with sudo privileges and follow the steps below. For an initial setup, you can visit this guide on Initial Server Setup with Ubuntu 22.04.

Install OpenJDK on Ubuntu 22.04

Because Jenkins is written in Java, you must have installed it on your server. First, update your local package index with the following command:

sudo apt update

Then, use the following command to install OpenJDK:

sudo apt install openjdk-11-jdk -y

Verify your Java installation by checking its version:

java -version
Output
openjdk version "11.0.18" 2023-01-17
OpenJDK Runtime Environment (build 11.0.18+10-post-Ubuntu-0ubuntu122.04)
OpenJDK 64-Bit Server VM (build 11.0.18+10-post-Ubuntu-0ubuntu122.04, mixed mode, sharing)

Installation Steps of Jenkins on Ubuntu 22.04

At this point, you need to add the Jenkins GPG key and Enable its repository. To do this, follow the steps below.

Add Jenkins GPG key

Jenkins packages aren’t available in the default Ubuntu 22.04 repository. So you need to add it manually to your server.

First, add the Jenkins GPG key by using the following curl command:

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

Add Jenkins Repository

Now you need to add the Jenkins repo to your Ubuntu server by using the following 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

Run System Update

At this point, run the system update by using the command below:

sudo apt update

Install Jenkins

Finally, use the following command to install Jenkins on Ubuntu 22.04:

sudo apt install jenkins -y

Jenkins Service Status

When your installation is completed, your Jenkis service must be started on your Ubuntu 22.04 automatically. To confirm it, run the command below:

sudo systemctl status jenkins
Output
● jenkins.service - Jenkins Continuous Integration Server
     Loaded: loaded (/lib/systemd/system/jenkins.service; enabled; vendor prese>
     Active: active (running) since Sat 2023-04-29 10:13:31 UTC; 5min ago
   Main PID: 4680 (java)
      Tasks: 44 (limit: 4575)
     Memory: 1.2G
        CPU: 1min 14.113s
     CGroup: /system.slice/jenkins.service
             └─4680 /usr/bin/java -Djava.awt.headless=true -jar /usr/share/java>

If the service is not running or active, you can use the following command:

sudo systemctl enable --now jenkins

Jenkins Administrator password

To access the Jenkins dashboard, you need your Jenkins admin password. By default, Jenkins’s password is available in the /var/lib/jenkins/secrets/. To find it, you can use the following command:

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

Jenkins Configuration through Web Interface

At this point, you can access your Jenkins web interface by typing your server’s IP address in your web browser followed by 8080:

http://your-server-ip:8080

You will see the Unlock Jenkins page. Enter your Jenkins initial admin password and click Continue.

Unlock jenkins

Next, you should choose which Jenkins plugins you want to install on Ubuntu 22.04. You can select plugins or the recommended ones. Here we choose Install suggested plugins.

Install Jenkins plugins

This will take some time to complete.

Then, you can create your first admin user. You can use this to log in and use Jenkins in the future.

Jenkins admin user

Access Jenkins Dashboard on Ubuntu 22.04

Finally, after following the other few steps you will have your Dashboard to start creating projects for testing and developing along with your developer’s Team.

Jenkins instance configuration
Start using jenkins on Ubuntu 22.04

You should see your Jenkins dashboard:

Jenkins dashboard Ubuntu 22.04

For more information, you can visit the Jenkins Docs page.

Conclusion

Jenkins is simple to set up and customize. Jenkins has many plugins that give it a lot of versatility. It delivers code instantaneously, generates a report after deployment, highlights errors in code or tests, and detects and resolves various issues in near real time. It’s also ideal for integration because it’s all done automatically. 

Hope you enjoy this guide on Install and Configure Jenkins on Ubuntu 22.04.

You may be interested in these articles:

Check and Install Security Updates on Ubuntu 22.04

Install Bitwarden on Ubuntu 20.04

Install Siege Stress Test on Ubuntu 20.04

Newsletter Updates

Enter your email address below and subscribe to our newsletter

Stay informed and not overwhelmed, subscribe now!