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.
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:
sudo apt update
Once the installation is complete, you can check the version of Java by running the following command:
The output should look something like this:
openjdk version "11.0.7" 2020-04-14
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:
wget -q -O - https://pkg.jenkins.io/debian/jenkins.io.key | sudo apt-key add -
Next, add the Jenkins repository to the system with:
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:
sudo apt update
Jenkins service will automatically start after the installation process is complete. You can verify it by printing the service status:
systemctl status jenkins
You should see something like this:
● jenkins.service - LSB: Start Jenkins at boot time
If you are installing Jenkins on a remote Ubuntu server that is protected by a firewall , you’ll need to open port
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:
sudo ufw allow proto tcp from <IP RANGE> or <IP ADDRESS> to any port 8080
If you need to allow access from anywhere run:
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:
sudo cat /var/lib/jenkins/secrets/initialAdminPassword
You should see a 32-character long alphanumeric password, as shown below:
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.