All Tutorials
How to install Jenkins on Ubuntu 20.04?
How to install Jenkins on Ubuntu 20.04?

How to install Jenkins on Ubuntu 20.04?

Learn how to seamlessly install and set up Jenkins, with our easy-to-follow, step-by-step guide. Leverage the power of Jenkins in the Ubuntu environment, boost productivity, and accelerate the development workflow. Get started with the installation process now!
Saurabh Dhingra
Founder, Uptut | Trainer & Consultant: DevOps, QA and IoT
DevOps
July 7, 2023
All trainings
How to install Jenkins on Ubuntu 20.04?

How to install Jenkins on Ubuntu 20.04?

Learn how to seamlessly install and set up Jenkins, with our easy-to-follow, step-by-step guide. Leverage the power of Jenkins in the Ubuntu environment, boost productivity, and accelerate the development workflow. Get started with the installation process now!

Introduction

In this tutorial, learn how to install Jenkins on Ubuntu 20.04, step-by-step. All prerequisites necessary for the installation process are also covered in this tutorial to ensure a smooth installation. It starts with a comprehensive description of Jenkins, prerequisites including hardware recommendations, followed by installation steps, and then about post-installation setup. By the end of this tutorial, you will have a Jenkins server ready and be able to start exploring Jenkins automation to streamline the software development process.

What is Jenkins?

Jenkins is an open-source automation server for automating tasks involved in the continuous integration and continuous delivery (CI/CD) process. The main purpose of Jenkins is to enable developers to automate repetitive tasks like building, testing, and deploying applications. It integrates with a wide range of plugins, tools, and technologies to extend its functionality. A few important tools that deserve mention are Git and Maven. 

Git is a source code management tool that enables developers to trigger automation whenever changes are made to the code repository. 

Maven, on the other hand, is a build automation and project management tool that helps in project dependency management, source code compilation, running tests, and packaging aspects. 

With these basic tools, along with Jenkins, developers can create an efficient and robust workflow. This tutorial also includes a procedure for how to install JDK for Jenkins in Ubuntu.

Prerequisite

Hardware recommendations-

The system needs an Ubuntu 20.04 server configured. Hardware recommendations for Jenkins, suggests the comprehensive hardware needed for Jenkins installations.

Minimum hardware requirements:

  • 256 MB of RAM
  • 1 GB of drive space (although 10 GB is a recommended minimum if running Jenkins as a Docker container)

Recommended hardware configuration for a small team:

  • 4GB of RAM
  • 50 GB of drive space

Install Java

The only prerequisite for Jenkins installation in Ubuntu 20.04 is Java, as Jenkins is a self-contained Java-based programme. It is recommended to use versions that do not predate Java 8. The most recommended versions are 8, 11, and 17. In this tutorial, steps to install Java 17 will be given. The steps to install JDK on Ubuntu are as follows:

sudo apt-get update

sudo apt-get install openjdk-17-jdk

Check for successful installation with the below command:

java -version

Install Git

Git installation is not a requirement for Jenkins in Ubuntu 20.04, but it is meaningless to have Jenkins without a source code pull mechanism. The steps to install Git are as follows:

sudo apt-get install git

Check for successful installation with the below command:

git -version

Get started with Jenkins

- Install Maven

Similar to Git, Maven installation is also not a requirement for Jenkins in Ubuntu 20.04, but Jenkins needs a build tool like Maven to play an expert-level game. Basic JDK tools can be used to build and run JUnit tests, but that will never leverage the benefits of having Jenkins and Ubuntu. The prerequisite for Maven installation is Java, which is already installed. The steps to install Maven are as follows:

sudo apt-get install maven

Check for successful installation with the below command:

maven -version

- Install Jenkins

Jenkins is installed in Ubuntu through apt. First, import and add the repository key to the system. This is used to ensure the latest version of Jenkins is used. Administrators must add the new keys to the system every time before attempting to update Jenkins. Jenkins provides the Debian Package Details, which can be added from the Debian-stable apt repository.

Install Jenkins on Ubuntu step by step using the list of commands given below:

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

Now, update the Debian apt repositories.

sudo apt-get update

Install Jenkins.

sudo apt-get install jenkins

Check for successful installation with the below command:

Jenkins -version

- Start Jenkins

Now Jenkins is installed. Jenkins services will be automatically started upon installation. To verify the status, use the below command:

sudo systemctl status jenkins
--
sudo systemctl status jenkins
    
-->

It should show the active status in the prompt. If not, use the below command to start Jenkins service.

sudo systemctl start jenkins

Check the status, to make sure the service is active

- Configure Firewalls

Jenkins services are active now. There are a few initial setups pending with Jenkins. To do it, the firewall rules have to be configured to reach Jenkins from the Web browser. The UFW tool is used to configure firewalls. By default, Jenkins runs on port 8080. Open the port using the below command:

sudo ufw allow 8080

Check the status.

sudo ufw status

If the status is inactive, enable the firewall using the command below:

sudo ufw enable

Check the status again.

sudo ufw status

The status will be active now, and traffic is allowed on 8080 from anywhere.

Post-installation set-up

All the steps above help in downloading, installing, and starting the Jenkins service. Now begins the post-installation set-up. This includes a few one-time activities like unlocking Jenkins, customizing it with plugins, and creating admin users.

Unlock Jenkins

To start with, type the server domain name or IP address along with port 8080 in the web browser's address bar, to access Jenkins web interface.

http://localhost:8080

or

sudo ufw status

As shown in the screenshot below, Jenkin's unlocking page should be displayed.

A screenshot of a computerDescription automatically generated with medium confidence

Get the link from the Unlock Jenkins page. Using the cat command in the terminal, get the initial password.

sudo cat /var/jenkins_home/secrets/initialAdminPassword

The terminal will now display a 32-character alphanumeric password. Copy the same and paste it into the Administrator password of the Unlock Jenkins page and click Continue.

Customizing plugins

Now the Customize Jenkins page will appear.

Choose any one option listed on the screen:

  1. Install suggested plugins: These have a list of recommended plugins, and on clicking this option, all the recommended plugins will be installed.
  2. Select plugins to install: Choose which plugins are needed based on the project’s needs. By default, all the suggested plugins will be selected for installation.

When there is no clear idea of which plugins are needed, choose Install suggested plugins. Customise the required plugins at a later point via the Manage Jenkins > Plugins page in Jenkins.

Creating the first admin user

After customising the plugins, Jenkins will ask for the creation of the first administrator user.

Provide the required details and click Save and Continue.

If the “Skip and continue as admin” option is chosen, a 32-character alphanumeric password serves as the default administrator account’s password. 

An Instance Configuration page will be displayed next to confirm the preferred URL for the Jenkins instance. After clicking Save and Finish, Jenkins is Ready! page will be displayed.

A screenshot of a computerDescription automatically generated with medium confidence

Click on Start using Jenkins to get the Jenkins Welcome page.

With this, the tutorial ends. ​​If you are looking for how do I install Jenkins on Ubuntu 20.04 latest guide, then hope it was a useful read for you.

Excited to upskill?

Learn LIVE from experts with your team. Request a free expert consultation and plan the training roadmap with Uptut.
talk to an expert
Thank you! Your submission has been received!
Oops! Something went wrong while submitting the form.