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, search > terminal)
- Java 8
A Brief Note on Jenkins
Jenkins is a 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 on Ubuntu (not 10 or 11). You can have multiple different versions of Java installed on your system. If you do, make sure Java 8 is set to the default.
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
sudo apt install openjdk-8-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 keys:
wget –q –O - https://pkg.jenkins.io/debian/jenkins.io.key | sudo apt-key add –
Note: GPG stands for Gnu Privacy Guard. This is an encryption key to verify that the software is authentic.
2. Next, open your /etc/apt/sources.list file for editing:
sudo nano /etc/apt/sources.list
3. Scroll to the bottom of the list, and add the following lines:
# Jenkins software repository deb https://pkg.jenkins.io/debian binary
4. Write the changes (Ctrl+O), then exit (Ctrl+X).
Step 3: Install Jenkins
1. To install Jenkins on Ubuntu, use the command:
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
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.
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.