Jenkins is a software package for software developers. It’s used to automate parts of the testing, build, delivery, and deployment of software.
This guide will help you install Jenkins on an Ubuntu 18.04 system.
- A system running Ubuntu 18.04 Bionic Beaver
- A user account with sudo privileges
- Access to a terminal window / command line (CTRL+ALT+T or search > terminal)
- Java 8 or 11
A Brief Note on Jenkins
Jenkins is a CI/CD software platform that supports continuous integration (CI) and continuous delivery (CD). CI pushes code changes regularly into the official repository. CD implements changes regularly through build, testing, and deployment.
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 this time, Jenkins only supports Java 8 and Java 11 on Ubuntu. You can have multiple different versions of Java installed on your system. If you do, make sure Java 8 or Java 11 is set to the default.
Note: Visit our article Jenkins Tutorial: Basics for Beginners to familiarize yourself with Jenkins and start using it skillfully.
Step 1: Install Java
If you already have Java installed on your system, skip ahead to the next section.
It is recommended that you install OpenJDK from the default repositories. Open a terminal window and enter the following:
sudo apt update
Install OpenJDK 8 with:
sudo apt install openjdk-8-jdk
Alternatively, install version 11:
sudo apt install openjdk-11-jdk
You’ll be asked to confirm the download and installation. Press
Y and hit Enter, then allow the process to finish.
Step 2: Add the Jenkins Repository
A software repository is a server that holds software packages for download. Jenkins isn’t included in the default Ubuntu repositories, so you’ll need to add it.
1. Start by importing the GPG key:
curl -fsSL https://pkg.jenkins.io/debian-stable/jenkins.io.key | sudo tee /usr/share/keyrings/jenkins-keyring.asc > /dev/null
The terminal does not output a message.
Note: GPG stands for Gnu Privacy Guard. This is an encryption key to verify that the software is authentic.
2. Next, add the Jenkins software repository to the sources list and provide the key for authentication:
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
The command adds the Long Term Support (LTS) stable release to the sources list.
Step 3: Install Jenkins
1. To install Jenkins on Ubuntu, use the following commands:
sudo apt update
sudo apt install jenkins
2. The system prompts you to confirm the download and installation. Press
Y and hit Enter, and the system downloads and installs Jenkins.
3. To check Jenkins was installed and is running enter:
sudo systemctl status jenkins
You should see a bright green entry that says
active (exited). This means the service is running.
4. Exit the status screen by pressing Ctrl+Z.
Step 4: Modify Firewall to Allow Jenkins
You need to open Port 8080 to allow Jenkins to communicate.
If you’re using the default UFW firewall, enter the following:
sudo ufw allow 8080
sudo ufw status
If you’re using a different firewall application, follow its specific instructions to allow traffic on Port 8080.
In the default UFW, if you haven’t configured the firewall it displays as inactive. You can enable UFW using the following:
sudo ufw enable
Note: If you need to change the port, check out our post How to Change Port for Jenkins.
Step 5: Set up Jenkins
1. To launch and set up Jenkins, open a web browser, and navigate to the IP address of your server:
Use the actual IP address or domain name for the server you’re using Jenkins on. For example, if you're running locally, use:
2. You should see a page that prompts you to Unlock Jenkins. You’ll need the default password. You can get the default password by switching to a command line and entering the following:
sudo cat /var/lib/jenkins/secrets/initialAdminPassword
3. The system returns an alphanumeric code. Enter that code, then click Continue.
4. Next, you are prompted to either Install suggested plugins or Select plugins to install. It’s fine to simply install the suggested plugins.
You can always install more plugins later. The system continues the initial Jenkins setup.
5. Then you will be prompted to Create First Admin User.
Enter the credentials you want to use for your Jenkins administrator, then Save and Continue.
6. After this, you should set up the Instance Configuration. This is the preferred network address for this Jenkins installation. Confirm the address you want to use for your server. This is most likely the same address you used to get to this configuration page. When you’re satisfied, click Save and Finish.
7. You should see a page that says Jenkins is ready!
You can click Start using Jenkins to open the Jenkins dashboard.
Note: Check out our guide on how to restart Jenkins manually - a useful practice while troubleshooting issues.
You should now have a working installation of Jenkins on your Ubuntu system.Next, discover how to setup jenkins on a Kubernetes cluster.