DEV Community

Cover image for How to Install Jenkins on Ubuntu
HostnExtra Technologies
HostnExtra Technologies

Posted on

How to Install Jenkins on Ubuntu

In this article, we’ll explain how to install Jenkins on Ubuntu 20.04

Jenkins is a free and open source automation server. Jenkins provides hundreds of plugins to support building, deploying and automating any project. Jenkins is Java-based, installed from Ubuntu packages or by downloading and running its web application archive (WAR) file — a collection of files that make up a complete web application to run on a server.

Prerequisites

A Ubuntu 20.04 installed dedicated server or KVM VPS.
A root user access or normal user with administrative privileges.

How to Install Jenkins on Ubuntu

Step 1 - Keep your server up to date

# apt-get update -y
# apt-get upgrade -y
Enter fullscreen mode Exit fullscreen mode

Step 2 - Install Java

Next, we will install OpenJDK 11.

# apt-get install -y default-jre
Enter fullscreen mode Exit fullscreen mode

To verify the installation, check the version using following command:

# java -version
Enter fullscreen mode Exit fullscreen mode

The output will be similar to the following:

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)
Enter fullscreen mode Exit fullscreen mode

Step 3 - Install Jenkins

Following command will install LTS release. LTS is chosen every 12 weeks from the stream of regular releases as the stable release for that time period.

Use following commands to install Jenkins:

# wget -q -O - https://pkg.jenkins.io/debian-stable/jenkins.io.key | sudo apt-key add -
# sudo sh -c 'echo deb https://pkg.jenkins.io/debian-stable binary/ > /etc/apt/sources.list.d/jenkins.list'
# sudo apt-get update
# sudo apt-get install jenkins -y
Enter fullscreen mode Exit fullscreen mode

Now that Jenkins and its dependencies are in place, we’ll start the Jenkins server.

Step 4 - Start and enable Jenkins

We need to start and enable Jenkins service. Use following commands:

# systemctl start jenkins

# systemctl enable jenkins
Enter fullscreen mode Exit fullscreen mode

Step 5 - Configure Firewall (Optional)

Assuming that you are using UFW firewall. By default, Jenkins runs on port 8080. We’ll open that port using ufw:

# ufw allow 8080
Enter fullscreen mode Exit fullscreen mode

Check ufw’s status to confirm the new rules:

# ufw status
Enter fullscreen mode Exit fullscreen mode

Step 5 - Setup Jenkins

First, we need to get default administrator password.

# cat /var/lib/jenkins/secrets/initialAdminPassword
Enter fullscreen mode Exit fullscreen mode

Above command will display administrator password. Copy the 32-character alphanumeric password from the terminal and paste it into the Administrator password field, then click Continue.

Install Jenkins on Ubuntu

Once you click to continue, you will get two options. You can select any option as per your choice or we suggest to go with Install Suggested Plugins. Once you click the Install suggested plugins option, which will immediately begin the installation process.

After that it will ask to create admin user. It’s possible to skip this step and continue as admin using the initial password we used above, but we recommend to take a moment to create the user.

Next, you’ll receive an Instance Configuration page that will ask you to confirm the preferred URL for your Jenkins instance. Confirm either the domain name for your server or your server’s IP address.

After confirming the appropriate information, click Save and Finish. You’ll receive a confirmation page confirming that “Jenkins is Ready!”

That’s it. The installation and configuration process has been completed successfully.

In this article, we have seen how to install Jenkins on Ubuntu 20.04.

Top comments (0)