Install Jenkins on Ubuntu 20.04 - Step by Step Process ?

Jenkins written in java is an open-source automation server. It is used to build, test, and document software projects. It allows you to automate a series of activities in order to complete the continuous integration process. 

With its user-friendly web-based dashboard, it becomes easier to manage some complicated tasks.

Here at LinuxAPT, as part of our Server management Services, we regularly help our Customers to perform related Jenkins queries on Ubuntu Linus Systems.

In this context, we shall look into how to install Jenkins on ubuntu 20.04 LTS. You must have sudo privileges in order to install Jenkins on your Ubuntu system.

Advantages of Jenkins on Ubuntu:

1. Increasing the reliability of the CI/CD process.

2. Ease of installation, configuration, and usage of the software.

3. A wide variety of Plugins which extends its capabilities.

4. Integration with other CI/CD tools.

5. Distribution of services. A developer can build, test, and deploy applications across multiple servers and platforms.

6. Being a free and open-source application.

Steps to install Jenkins on Ubuntu:

1. Install Java

For Jenkins to run, you will need to first install Java on your system. Here, we will use OpenJDK which is the open-source implementation of the Java platform. 

You can install OpenJDK in Ubuntu as follows:

$ sudo apt install openjdk-11-jdk

Enter sudo password. When prompted with the y/n option, press y to carry on. 

After which the OpenJDk installation will be started on your system.

Once finished, you can verify the installation by executing the command below in the Terminal:

$ java --version

2. Install Jenkins

Jenkins is not available in the Ubuntu repositories. We can install it by adding its repository to the system’s local repositories. 

Here are the steps to install Jenkins:

i. Download and add Jenkins repository key to your apt keyring. By doing this, your system will trust the added repository. 

Execute the command below to add the Jenkins repository key.

$ wget -q -O - | sudo apt-key add -

ii. Add Jenkins repository to your system local repositories using the command below in the Terminal:

$ sudo sh -c 'echo deb binary/ > /etc/apt/sources.list.d/jenkins.list'

iii. Update the system's repository index using this command:

$ sudo apt update

iv. Now, to install Jenkins, run the command below in the Terminal:

$ sudo apt install jenkins

Enter sudo password. When prompted with the y/n option, press y to carry on. 

After which the Jenkins installation will be started on your system.

Once the installation of Jenkins is completed, you can start its service using the command below in the Terminal:

$ sudo systemctl start Jenkins

Then to confirm if the service is running fine, run this command in the Terminal:

$ sudo systemctl status Jenkins

If the service is running fine, you will see active (running) in the output.

3. Adjust Firewall

If you want to access Jenkins from the same system on which it is installed, you don't need to follow this step. 

However, if you have installed Jenkins to the system secured by a firewall and you need to access it from another system on the network, you will need to allow connections to port 8080 in the firewall.

To verify if the firewall is running on your Ubuntu system, execute the below command:

$ sudo ufw status

If a firewall is running on your system, you will see the active status in the output.

To allow the connections to port 8080, add a rule in the firewall by executing the below command in the Terminal:

$ sudo ufw allow 8080

Then to verify if the rule has been added to the firewall, execute this command:

$ sudo ufw status

The output below verifies that a rule has been added that allows the connection to port 8080 from anywhere.

4. Post-installation setup wizard

Now you will need to setup Jenkins through a post-installation wizard.

i. Open your web browser and access http://ip-address:8080. Replace ip-address by your system's IP address where Jenkins is installed.

You will see the following Unlock Jenkins page containing the path of the file containing the password. 

You will need this password to unlock Jenkins.

To find this password, type cat followed by the link displayed on the following page like this:

$ cat /var/lib/jenkins/secrets/initialAdminPassword

The above command will display the password on the Terminal screen. Copy this password and paste it into the Administrator password field in the Unlock Jenkins page.

Then click Continue.

Then in Customize Jenkins, click Install suggested plugins if you are not sure what plugins to install. 

Or click Select plugins to install if you want to manually choose the plugins for installation.

Next, the installation of plugins will be started and you will see the progression in the setup wizard.

Once the installation is finished, the wizard will ask you to create your first admin user. Provide details for the admin user and hit Save and Continue. 

Alternatively, you can skip this step by clicking Skip and continue as admin. 

This will continue the setup using the default admin user and the password we have used earlier.

Next, you will see asked to set the preferred URL for the Jenkins instance. If you are okay with the URL showing in the screen, click Save and Finish.

Then click Start using Jenkins.

It will redirect you to the Jenkins Dashboard and now you can start using Jenkins.

How to Uninstall Jenkins from Ubuntu ?

In case you need to uninstall/remove Jenkins, you can do so easily using the command below in the Terminal:

$ sudo apt remove Jenkins

Enter sudo password. When prompted with the y/n option, press y to carry on. 

After which the Jenkins will be removed from your system.

[Need urgent assistance in installing any packages on Ubuntu Systems ? We can help you now. ]

This article covers how you can install Jenkins on Ubuntu OS. For further information about Jenkins, visit its official documentation.

Jenkins is an open-source automation server that can be used to easily set up continuous integration and continuous delivery (CI/CD) pipelines.

Continuous integration (CI) is a DevOps practice in which team members regularly commit their code changes to the version control repository, after which automated builds and tests are run. 

Continuous delivery (CD) is a series of practices where code changes are automatically built, tested, and deployed to production.

To install Jenkins on Ubuntu 20.04 as a standalone service:

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

$ sudo apt update
$ sudo apt install openjdk-11-jdk

2. Once the installation is complete, verify it by checking the Java version:

# java -version

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

# wget -q -O - | sudo apt-key add -

4. Next, add the Jenkins repository to the system with:

# sudo sh -c 'echo deb binary/ > /etc/apt/sources.list.d/jenkins.list'

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

# sudo apt update
# sudo apt install jenkins

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

# systemctl status jenkins

Related Posts