How to Install Jenkins on Ubuntu 18.04

April 23, 2020

Introduction

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.

How to install Jenkins on Ubuntu.

Prerequisites

  • 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
openjdk 11 installation terminal

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.

jenkins service active

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
ufw firewall status active port 8080

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:

http://ip_address_or_domain:8080

Use the actual IP address or domain name for the server you’re using Jenkins on. For example, if you're running locally, use:

http://localhost:8080
jenkins sign in page administrator

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.

customize jenkins plugins page

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.

jenkins create first admin user page

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!

jenkins completed setup page

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.

Conclusion

You should now have a working installation of Jenkins on your Ubuntu system. Next, discover how to setup jenkins on a Kubernetes cluster.

If you are using a different distribution of Linux, we also have a guide on how to install Jenkins od Debian 10, and how to install Jenkins on CentOS.

Was this article helpful?
YesNo
Sofija Simic
Sofija Simic is an experienced Technical Writer. Alongside her educational background in teaching and writing, she has had a lifelong passion for information technology. She is committed to unscrambling confusing IT concepts and streamlining intricate software installations.
Next you should read
How to Install Apache Maven on CentOS 7
March 20, 2019

Apache Maven is a project management tool for developing Java applications designed to provide...
Read more
How to Install Apache Tomcat 9 on Ubuntu 18.04
July 2, 2019

Apache Tomcat is a free, open-source, lightweight application server used for Java-based web...
Read more
How to Install Jenkins on Kubernetes Cluster
March 3, 2020

Use a provided set of YAML files to deploy scalable Jenkins on Kubernetes in 4 easy steps.
Read more
How to Install Jenkins on Debian 10 (Buster)
June 15, 2020

If you are a software developer working on a Debian 10 Buster you may want to install Jenkins.
Read more
  • © 2022 Copyright phoenixNAP | Global IT Services. All Rights Reserved.