In this article, We are going to learn how to install Jenkins on Ubuntu 20-04. Jenkins is an Open Source Continuous Integration tool that written in Java. It is a free software that can be used to build, test, and deploy software. In this article I will explain how to install Jenkins on Ubuntu 20.04 as a standalone service.

Installing Java

Jenkins is written in Java and requires Java 8 or later to be installed on the system. We’ll install OpenJDK 11 , the open-source implementation of the Java Platform.

Run the following commands as root or user with sudo privileges or root to install OpenJDK 11:

1
2
sudo apt update
sudo apt install openjdk-11-jdk

Once the installation is complete, you can check the version of Java by running the following command:

1
java -version

The output should look something like this:

1
2
3
openjdk version "11.0.7" 2020-04-14
OpenJDK Runtime Environment (build 11.0.7+10-post-Ubuntu-3ubuntu1)
OpenJDK 64-Bit Server VM (build 11.0.7+10-post-Ubuntu-3ubuntu1, mixed mode, sharing)

Installing Jenkins

To install Jenkins on Ubuntu, we need to enable the Jenkins APT repository, import the repository GPG key, and install the Jenkins package.

Import the GPG keys of the Jenkins repository using the following wget command:

1
wget -q -O - https://pkg.jenkins.io/debian/jenkins.io.key | sudo apt-key add -

Next, add the Jenkins repository to the system with:

1
sudo sh -c 'echo deb http://pkg.jenkins.io/debian-stable binary/ > /etc/apt/sources.list.d/jenkins.list'

Once the Jenkins repository is enabled, update the apt package list and install the latest version of Jenkins by typing:

1
2
sudo apt update
sudo apt install jenkins

Jenkins service will automatically start after the installation process is complete. You can verify it by printing the service status:

1
systemctl status jenkins

You should see something like this:

1
2
3
4
● jenkins.service - LSB: Start Jenkins at boot time
Loaded: loaded (/etc/init.d/jenkins; generated)
Active: active (exited) since Thu 2020-07-16 20:22:12 UTC; 15min ago
...

Adjusting Firewall

If you are installing Jenkins on a remote Ubuntu server that is protected by a firewall , you’ll need to open port 8080.

Typically, you would want to allow access to the Jenkins server only from a specific IP address or IP range. To do it, you would run the following command:

1
sudo ufw allow proto tcp from <IP RANGE> or <IP ADDRESS> to any port 8080

If you need to allow access from anywhere run:

1
sudo ufw allow 8080

Setting Up Jenkins

To set up your new Jenkins installation, open your browser, type your domain or IP address followed by port 8080, http://your_ip_or_domain:8080.

After that Unlock Jenkins page will load and prompting you to enter the Administrator password that is created during the installation. To copy it ssh to your server and run the following command:

1
sudo cat /var/lib/jenkins/secrets/initialAdminPassword

You should see a 32-character long alphanumeric password, as shown below:

1
06cbf25d811a424bb236c76fd6e04c47

Copy the password from the terminal, paste it into the “Administrator password” field and click “Continue”.

On the next screen, the setup wizard will ask you whether you want to install suggested plugins or you want to select specific plugins.

Click on the “Install suggested plugins” box and the installation process will start immediately.

Once the plugins are installed, you will be prompted to set up the first admin user. Fill out all required information and click “Save and Continue”.

The next page will ask you to set the URL for your Jenkins instance. The field will be populated with an automatically generated URL.

Confirm the URL by clicking on the Save and Finish button, and the setup process will be completed.

Click on the Start using Jenkins button, and you will be redirected to the Jenkins dashboard logged in as the admin user you have created in one of the previous steps.

At this point, you’ve successfully installed Jenkins on your server.

Conclusion

If you have any issue regarding this post, mention your issue in comment section or reach me through my E-mail.

Happy Coding