How to install and Configure Jenkins in Ubuntu 20.04

In this guide we are going to explore how to install and set up jenkins in Ubuntu 20.04 server.

Jenkins is an open source automation server which enables developers around the world to reliably build, test, and deploy their software. It is a popular open source automation tool to perform continuous integration and build automation. Jenkins allows to execute a predefined list of steps, e.g. to compile golang source code to build build binary file. The trigger for this execution can be time or event based.

Possible steps executed by Jenkins are for example:

  • Cloning the code from source control system.
  • execute a command to install dependencies required for the code to run
  • Run tests for the software
  • build the software to get an executable
  • Publish test results
  • publish the resulting binary code

Jenkins monitors the execution of the steps and allows to stop the process, if one of the steps fails. Jenkins can also send out notifications in case of a build success or failure.

Jenkins can be extended by additional plug-ins. For example, you can install plug-ins to support building and testing Android applications.

# Requirements

  • A Linux system with Ubuntu 20.04 server (At least 2GB of Ram)
  • A user account with sudo or root privileges
  • Access to a terminal window/command line
  • Recent Java version installed

# Table of content

  1. Ensuring that the system is up to date
  2. Install Java
  3. Install Jenkins
  4. Starting and enabling jenkins
  5. Accessing Jenkins
  6. Optional: Accessing jenkins using a domain

# 1. Ensuring that the system is up to date

Before proceeding, ensure that your system has updated packages. Use this command to achieve this:

sudo apt update
sudo apt upgrade -y

# 2. Install Java

Ensure that java is working as expected. Type this command to check the java version

java -version

If that command results in an error, you need to install java runtime env.

sudo apt install -y default-jre

# 3. Install Jenkins

First add the key to your system:

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

Then add the following entry in your /etc/apt/sources.list:

deb binary/

Update your local package index, then finally install Jenkins:

sudo apt-get update
sudo apt-get install jenkins

# 4. Starting and enabling jenkins

Ensure that jenkins is tunning as extected by checking the systemd service status

sudo systemctl status jenkins

You should see something like this:

● jenkins.service - LSB: Start Jenkins at boot time
     Loaded: loaded (/etc/init.d/jenkins; generated)
     Active: active (exited) since Sat 2021-07-31 17:22:57 UTC; 5s ago
       Docs: man:systemd-sysv-generator(8)
    Process: 18175 ExecStart=/etc/init.d/jenkins start (code=exited, status=0/SUCCESS)

Jul 31 17:22:55 frhb64566ds systemd[1]: Starting LSB: Start Jenkins at boot time...
Jul 31 17:22:55 frhb64566ds jenkins[18175]: Correct java version found
Jul 31 17:22:55 frhb64566ds jenkins[18175]:  * Starting Jenkins Automation Server jenkins
Jul 31 17:22:55 frhb64566ds su[18214]: (to jenkins) root on none
Jul 31 17:22:55 frhb64566ds su[18214]: pam_unix(su-l:session): session opened for user jenkins by (uid=0)
Jul 31 17:22:56 frhb64566ds su[18214]: pam_unix(su-l:session): session closed for user jenkins
Jul 31 17:22:57 frhb64566ds jenkins[18175]:    ...done.
Jul 31 17:22:57 frhb64566ds systemd[1]: Started LSB: Start Jenkins at boot time.

# 5. Accessing Jenkins

Access the jenkins server using the public ip on port 8080. If you are accessing the jenkins server locally, use


Get the jenkins public ip

curl -4

You can then navigate to http://public_ip:8080

# 6. Optional: Accessing jenkins using a domain name

If you want to access jenkins using a domain name, you can use something like nginx to proxy traffic. Nginx allows you to proxy the traffic and terminate ssl if need be.

Install nginx

sudo apt install -y nginx

Ensure that nginx is running

sudo systemctl status nginx

Create an nginx server for jenkins in /etc/nginx/conf.d with the content to serve:

File /etc/nginx/conf.d/jenkins.conf

server {
    listen 80;
    listen [::]:80;
    server_tokens off;

    ## Deny illegal Host headers
    if ($host !~* ^($ ) {
        return 444;

    location / {
          proxy_set_header   Host $host;
          proxy_set_header   X-Forwarded-For $proxy_add_x_forwarded_for;
          proxy_set_header   X-Forwarded-Host $server_name;
          proxy_set_header   X-Real-IP $remote_addr;
          proxy_set_header   X-Scheme $scheme;
          proxy_connect_timeout 60s;
          proxy_send_timeout 60s;
          proxy_read_timeout 60s;

Restart nginx:

sudo systemctl restart nginx

Map the A record of the domain to the IP address of your server and you should be able to access it using

# 7. Configuring jenkins

The first time you access the jenkins server using the domain, you will be greeted with a getting started screen asking you to Unlock jenkins with an admin password from this path /var/lib/jenkins/secrets/initialAdminPassword in the server.

Get the pasword by typing this

cat /var/lib/jenkins/secrets/initialAdminPassword

Citizix - Jenkins install unlock

Citizix – Jenkins install unlock

Upon entering the password, you will be taken to plugin install page. You have an option of installing common plugins or choosing what plugins to install.

I always prefer to custom pick plugins I want installed so I have control on what plugins are installed and what not.

Citizix - Cuztomize jenkins

Citizix – Cuztomize jenkins

Once the plugin installation is done, you will be redirected to a page to create Jenkins First User. I always create an Admin user then choose a strong password.

Citizix - Jenkins Create First Admin User

Citizix – Jenkins Create First Admin User

After that Ensure the correct URL is set in the last page of the instance configuration page. After this you will be redirected to the jenkins dashboard page.

From here you can Create jenkins jobs and use jenkins as you would wat.

comments powered by Disqus
Citizix Ltd
Built with Hugo
Theme Stack designed by Jimmy