Development

How to Install Jenkins on Ubuntu 22.04

Captain Salem 3 min read

How to Install Jenkins on Ubuntu 22.04

Jenkins is a free and open-source automation server with the aim of providing automation for repetitive tasks in continuous integration (CI) services. Jenkins is built on Java and can be installed on various systems, including; Windows, Linux, and macOS.

In this tutorial, we will learn how to install Jenkins on Ubuntu 22.04, we will also cover some basic Jenkins configurations, allowing you to explore Jenkins in simple steps.

Requirements

To follow along with this tutorial, you will need the following:

  1. Ubuntu 22.04 system
  2. Java JDK 11 and above installed -> https://www.geekbits.io/how-to-install-amazon-corretto-jdk-on-ubuntu/
  3. sudo permissions
  4. network connectivity

Install Jenkins

Let us learn how we can install Jenkins on the Ubuntu system. Unfortunately, using the Jenkins provided by the Ubuntu package manager can result in an older version of the system.

Start by updating your system repositories with the command:

sudo apt-get update

Next, add the Jenkins repository key to your system with the command:

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

Next, add the Jenkins apt repository with the 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

In the next step, update the local package index and install Jenkins with the commands:

sudo apt-get update
sudo apt-get install fontconfig jenkins -y

The command above should download and install Jenkins on your Ubuntu system.

Starting Jenkins

We can start the service once we have installed Jenkins on our system. We can use the systemctl command as shown:

sudo systemtctl start jenkins

The command should start Jenkins server on your system. You can check the status of the service using the command:

sudo systemctl status jenkins

The command should return the output as shown:

● jenkins.service - Jenkins Continuous Integration Server
     Loaded: loaded (/lib/systemd/system/jenkins.service; enabled; preset: enabled)
     Active: active (running) since Sat 2023-05-27 12:18:51 UTC; 47s ago
   Main PID: 4174 (java)
      Tasks: 48 (limit: 9492)
     Memory: 2.3G
        CPU: 48.446s
     CGroup: /system.slice/jenkins.service
             └─4174 /usr/bin/java -Djava.awt.headless=true -jar /usr/share/java/jenkins.war --webroot=/var/cache/jenkins/war --httpPort=80

Now that Jenkins is up and running, open your browser and access the Jenkins dashboard to complete the initial setup.

Jenkins Initial Setup

To set up your installation, visit Jenkins on its default port, 8080, using your server domain name or IP address: http://your_server_ip_or_domain:8080

This should take you to the Jenkins initial page:

image-20230527152234316
image-20230527152234316

In the terminal window, paste the command in the Jenkins setup page to retrieve the Jenkins password.

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

Copy and paste the password into the Administrator password field, then click Continue.

The next section presents the option of installing suggested plugins or selecting specific plugins:

image-20230527152500656
image-20230527152500656

We’ll click the **Install suggested Plugins option, immediately beginning the installation process.

The next step is setting up your Jenkins cluster’s admin user.

image-20230527152755484
image-20230527152755484

You’ll receive an Instance Configuration page asking you to confirm the preferred URL for your Jenkins instance. Confirm either the domain name for your server or your server’s IP address:

image-20230527152843633
image-20230527152843633

Once completed, you should see a “Jenkins is Ready” message.

image-20230527152921316
image-20230527152921316

Click Start using Jenkins to visit the main Jenkins dashboard.

Conclusion

This tutorial taught you how to install and configure Jenkins for first use. It is good to remember that Jenkins is extensive, and there is a lot more you can do to secure and configure Jenkins to your needs. You can check the documentation to learn more.

Share
Comments
More from Cloudenv

Cloudenv

Developer Tips, Tricks and Tutorials.

Great! You’ve successfully signed up.

Welcome back! You've successfully signed in.

You've successfully subscribed to Cloudenv.

Success! Check your email for magic link to sign-in.

Success! Your billing info has been updated.

Your billing was not updated.