How to Install and Setup Jenkins on Ubuntu 20.04

how to install jenkins on ubuntu 20.04 server

Jenkins server is a free and open source java platform. Jenkins is an automation server and it used to automate the development processes. Jenkins is used for CI/CD pipelines.

This is the complete tutorial to learn how to install and set up the Jenkins on your Ubuntu 20.04 server.

Table of Content:

  • Install Java
  • Install Jenkins
  • Setup Jenkins

Install Java:

Jenkins needs java to be installed on your Ubuntu 20.04 server because it’s a java based application. Java version must be 8 or more. For this tutorial, we will choose OpenJDK 11. To install java on Ubuntu 20.04 server run the following command. Before installing OpenJDK adds the PPA repository, then install java on your Ubuntu server.

sudo apt update
sudo add-apt-repository ppa:openjdk-r/ppa

After installation of java check the java version.

java -version
Output

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

Successfully we installed java on ubuntu 20.04 server.

Install Jenkins:

After installing java on your Ubuntu 20.04 server then enable the APT repository of Jenkins and import the Jenkins repository GPG key then install Jenkins.

To import the GPG keys of Jenkins repository with the following command.

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

To add the APT repository of Jenkins to your ubuntu 20.04 server run commands below.

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

After enabling Jenkins repository then update the apt package and install Jenkins.

sudo apt update

If you’re getting any errors run the command below after that run the above command.

sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 9B7D32F2D50582E6

Now install the Jenkins

sudo apt install jenkins

After the Jenkins installation it starts automatically. To check the status run the command below.

systemctl status jenkins
Output

● jenkins.service - LSB: Start Jenkins at boot time
     Loaded: loaded (/etc/init.d/jenkins; generated)
     Active: active (exited) since Thu 2020-07-23 15:49:40 UTC; 3min 31s ago
       Docs: man:systemd-sysv-generator(8)
      Tasks: 0 (limit: 1164)
     Memory: 0B
     CGroup: /system.slice/jenkins.service

Jul 23 15:49:39 ip-172-31-19-151 systemd[1]: Starting LSB: Start Jenkins at boot time...
Jul 23 15:49:39 ip-172-31-19-151 jenkins[8124]: Correct java version found
Jul 23 15:49:39 ip-172-31-19-151 jenkins[8124]:  * Starting Jenkins Automation Server jenkins
Jul 23 15:49:39 ip-172-31-19-151 su[8186]: (to jenkins) root on none
Jul 23 15:49:39 ip-172-31-19-151 su[8186]: pam_unix(su-l:session): session opened for user jenkins by (uid=0)
Jul 23 15:49:39 ip-172-31-19-151 su[8186]: pam_unix(su-l:session): session closed for user jenkins
Jul 23 15:49:40 ip-172-31-19-151 jenkins[8124]:    ...done.
Jul 23 15:49:40 ip-172-31-19-151 systemd[1]: Started LSB: Start Jenkins at boot time.

Setup Jenkins:

Before setup the Jenkins you have to enable the 8080 port on your server. To setup Jenkins access http://your_ip:8080 or http://domain_name:8080.

Now you will see the Jenkins page and its asking for admin password.

To get the admin password run the command below.

sudo cat /var/lib/jenkins/secrets/initialAdminPassword
Output
bd9aaea7c8054c41af2da25e43d1bdb7

Copy and paste the password on the admin password field then click continue now you see the plugin’s  installation page.

Select and install suggested plugins, now you will see the installing plugin process.

After installing plugins and create admin user and password, then click Save and continue.

create admin user

Configure your Jenkins server URL and click Save and Finish.

You have finished the Jenkins installation, now click Start using Jenkins.

That’s all now you see your Jenkins Dashboard.

jenkins dashboard

Conclusion:

That’s all we have installed Jenkins on our ubuntu 20.04. In this tutorial we have learned how to install and setup Jenkins on ubuntu 20.04 server.

Next Article: How to Install Mysql on Ubuntu

Leave a Reply

Your email address will not be published. Required fields are marked *

You May Also Like
how to install php on ubuntu 20.04
Read More

How to Install PHP on Ubuntu 20.04 Machine

Table of Contents Hide Add PPA:Install PHP on ubuntu:To install PHP 7.0To install PHP 7.1To install PHP 7.2To install PHP 7.3To install PHP 7.4Conclusion: PHP is a common purpose scripting language…