How to Install Jenkins on Ubuntu 22.04

How to Install Jenkins on Ubuntu 22.04

·

2 min read

Jenkins is an open-source automation server used for Continuous Integration (CI) and Continuous Delivery (CD). In this guide, we will walk through the steps to install Jenkins on Ubuntu 22.04.

Table of Contents

  • Prerequisites

  • Step 1. Update the System

  • Step 2. Install Java

  • Step 3. Install Jenkins

  • Step 4. Complete Jenkins Installation

Prerequisites

Before you begin, ensure you have the following:

  • A server running Ubuntu 22.04

  • User privileges: root or a non-root user with sudo privileges

Step 1. Update the System

Start by updating your package list and upgrading existing packages to the latest versions:

sudo apt-get update -y && sudo apt-get upgrade -y

Step 2. Install Java

Jenkins requires Java to run. Install OpenJDK 11 with:

sudo apt install openjdk-11-jdk -y

Verify the Java installation:

java --version

You should see an output similar to this:

openjdk 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)

Step 3. Install Jenkins

Add the Jenkins repository and its key:

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

Update your package list and install Jenkins:

sudo apt update -y
sudo apt install jenkins -y

Start and enable the Jenkins service:

sudo systemctl start jenkins && sudo systemctl enable jenkins

Check the status of the Jenkins service:

sudo systemctl status jenkins

You should get an output indicating that Jenkins is running:

● jenkins.service - Jenkins Continuous Integration Server
     Loaded: loaded (/lib/systemd/system/jenkins.service; enabled; vendor preset: enabled)
     Active: active (running) since Thu 2023-04-06 15:17:46 CDT; 4min 1s ago
   Main PID: 22232 (java)
      Tasks: 45 (limit: 4571)
     Memory: 1.2G
        CPU: 1min 32.203s
     CGroup: /system.slice/jenkins.service
             └─22232 /usr/bin/java -Djava.awt.headless=true -jar /usr/share/java/jenkins.war --webroot=/var/cache/jenkins/war --httpPort=8080

Step 4. Complete Jenkins Installation

To complete the Jenkins installation, follow these steps:

  1. Open your web browser and navigate to http://your_server_ip_or_domain:8080.

  2. You will see the "Unlock Jenkins" screen.

  3. Retrieve the initial administrator password with the following command:

     sudo cat /var/lib/jenkins/secrets/initialAdminPassword
    
  4. Copy the password from the command line and paste it into the "Administrator password" field, then click "Continue".

  5. On the "Customize Jenkins" page, select "Install suggested plugins".

  6. Once the plugins are installed, create your first admin user and configure the instance as needed.

  7. Finally, click "Save and Finish" and then "Start using Jenkins".

Congratulations! Jenkins is now installed and ready to use on your Ubuntu 22.04 server.

Did you find this article valuable?

Support NavyaDevops by becoming a sponsor. Any amount is appreciated!