Install and Setup Jenkins on Ubuntu 20.04

|
Last Updated:
|
|
install jenkins ubuntu

Follow through this guide to install and setup Jenkins on Ubuntu 20.04. Jenkins is an open source Java based automation server that can be used by the developers to reliably build, test, and deploy their software.

Installing Jenkins on Ubuntu 20.04

Prerequisites

Hardware Requirements

Recommended hardware requirements for a small team:

  • 1 GB+ of RAM
  • 50 GB+ of drive space

Software requirements

Install Java

Jenkins is a Java based tool. It supports Java 8 and Java 11 (since Jenkins 2.164 and 2.164.1) run time environment.

Thus, in this setup, we will use Java 11. Execute the command below to install Java 11 on Ubuntu 20.04;

apt update
apt install openjdk-11-jdk

Once the installation is done, you can verify the version of installed Java as follows

java -version
openjdk version "11.0.10" 2021-01-19
OpenJDK Runtime Environment (build 11.0.10+9-Ubuntu-0ubuntu1.20.04)
OpenJDK 64-Bit Server VM (build 11.0.10+9-Ubuntu-0ubuntu1.20.04, mixed mode, sharing)

Install Jenkins

Create Jenkins Repository on Ubuntu 20.04

Jenkins is not available on the default Ubuntu 20.04 repos. As such, you need to create its repository as follows;

wget -q -O - https://pkg.jenkins.io/debian-stable/jenkins.io.key | sudo apt-key add -
echo "deb https://pkg.jenkins.io/debian-stable binary/" > /etc/apt/sources.list.d/jenkins.list

Update the package cache;

apt update

Next, install Jenkins on Ubuntu 20.04;

apt install jenkins

Running Jenkins on Ubuntu 20.04

Upon installation, Jenkins is started and set to run on system boot;

systemctl status jenkins
● jenkins.service - LSB: Start Jenkins at boot time
     Loaded: loaded (/etc/init.d/jenkins; generated)
     Active: active (exited) since Wed 2021-02-17 21:09:11 CET; 2min 8s ago
       Docs: man:systemd-sysv-generator(8)
      Tasks: 0 (limit: 2286)
     Memory: 0B
     CGroup: /system.slice/jenkins.service

Feb 17 21:09:10 ubuntu-2gb-hel1-1 systemd[1]: Starting LSB: Start Jenkins at boot time...
Feb 17 21:09:10 ubuntu-2gb-hel1-1 jenkins[14087]: Correct java version found
Feb 17 21:09:10 ubuntu-2gb-hel1-1 jenkins[14087]:  * Starting Jenkins Automation Server jenkins
Feb 17 21:09:10 ubuntu-2gb-hel1-1 su[14135]: (to jenkins) root on none
Feb 17 21:09:10 ubuntu-2gb-hel1-1 su[14135]: pam_unix(su-l:session): session opened for user jenkins by (uid=0)
Feb 17 21:09:10 ubuntu-2gb-hel1-1 su[14135]: pam_unix(su-l:session): session closed for user jenkins
Feb 17 21:09:11 ubuntu-2gb-hel1-1 jenkins[14087]:    ...done.
Feb 17 21:09:11 ubuntu-2gb-hel1-1 systemd[1]: Started LSB: Start Jenkins at boot time.
systemctl is-enabled jenkins

Output;

enabled

Accessing Jenkins Web Interface

Jenkins listens on port 8080/TCP by default.

netstat -altnp | grep :80
tcp6       0      0 :::8080                 :::*                    LISTEN      14150/java

To be able to access it externally, you need to open this port on UFW (if it is enabled);

ufw allow 8080/tcp

Once that is done, then you can navigate to browser and access Jenkins using the URL http://server-IP-or-resolvable-hostname:8080.

Unlock Jenkins

You can obtain the password from the file, /var/lib/jenkins/secrets/initialAdminPassword.

cat /var/lib/jenkins/secrets/initialAdminPassword
unlock jenkins

Install Jenkins Plugins

In order to extend the functionality of Jenkins, you can install the suggested plugins. Thus click either of the boxes install the plugins;

install jenkins plugins

Create Admin Account

Once the plugin installation completes, you are then prompted to create the first Jenkins admin account.

Install and Setup Jenkins on Ubuntu 20.04

You can however skip this step and continue as the default admin user. Otherwise, enter the details above and save and continue

Instance Configuration

Define the Jenkins URL;

instance url jenkins

Click Save and Finish and start using Jenkins.

Jenkins Web Dashboard.

jenkins dashboard

Read more on how to use Jenkins on the documentation page.

Using Jenkins

Reference

Installing Jenkins

Other Tutorials

Install SonarQube on Ubuntu 20.04

Install Nexus Repository Manager on Ubuntu 20.04

Install and setup GVM 20.08 on Debian 10

Install Signal Messenger on Ubuntu 20.04

Install NoMachine on Ubuntu 20.04

SUPPORT US VIA A VIRTUAL CUP OF COFFEE

We're passionate about sharing our knowledge and experiences with you through our blog. If you appreciate our efforts, consider buying us a virtual coffee. Your support keeps us motivated and enables us to continually improve, ensuring that we can provide you with the best content possible. Thank you for being a coffee-fueled champion of our work!

Photo of author
gen_too
Co-founder of Kifarunix.com, Linux Tips and Tutorials. Linux/Unix admin and author at Kifarunix.com.

Leave a Comment