Step 1: Install Java
Jenkins requires the Java Runtime Environment (JRE). This guide uses OpenJDK for the Java environment. OpenJDK is a Development Kit, and includes the Java Runtime Environment.
At the time of writing this article, Jenkins only supports Java 8 and Java 11 on Ubuntu. You can have multiple versions of Java installed on Ubuntu. If you do, make sure Java 8 or Java 11 is set as the default version.
Follow the steps below to install Java on Ubuntu:
1. First, open a terminal window and update the system package repository by running:
sudo apt update
Enter your administrator password and wait for the update to complete.
2. Depending on which Java version you want to install, Java 8 or 11, run one of the following commands:
To install OpenJDK 8, run:
sudo apt install openjdk-8-jdk -y
To install OpenJDK 11, run:
sudo apt install openjdk-11-jdk -y
Step 2: Add Jenkins Repository
It is recommended to install Jenkins using the project-maintained repository, rather than from the default Ubuntu repository. The reason for that is because the Jenkins version in the default Ubuntu repository might not be the latest available version, which means it could lack the latest features and bug fixes.
Follow the steps below to add the Jenkins repository to your Ubuntu system.
Debian/Ubuntu LTS release
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
Step 3: Install Jenkins
After setting up the prerequisites, follow the steps below to install Jenkins on Ubuntu:
1. Update the system repository one more time. Updating refreshes the cache and makes the system aware of the new Jenkins repository.
sudo apt update
2. Install Jenkins by running:
sudo apt install jenkins -y
Wait for the download and installation to complete.