billysoftacademy.com

A Step by Step Guide to Installing Jenkins on Linux Ubuntu

Introduction

Jenkins is an open-source automation server that allows developers to easily create and manage continuous integration / continuous delivery (CI/CD) pipelines. It can be used to automate building, testing, and deploying applications. Jenkins is highly extensible and has a wide variety of plugins available. With its web-based user interface, you can quickly set up automated jobs that will help you save time and effort in your development workflow. Additionally, the security features provided by Jenkins make it a great choice for organizations that must ensure their data remains secure during software development. Read this video right up to the end to learn how to quickly and easily set up Jenkins on Ubuntu 22.04 LTS.

Requirements

The following is a list of items that are needed to complete this tutorial successfully:

1) Linux Ubuntu Server 22.04 LTS.
2) A server with a dual core processor or better, 50GB of free disk space and 4GB of RAM.
3) For cloud deployment you will also need a public static IP address and a fully qualified domain name.
4) An SSH client such as Putty or the Terminal app on macOS.
5) A general understanding of Linux commands.

Overview

Before we begin, let’s take a look at an overview of the steps covered in this tutorial:

1) Open an SSH connection to your Ubuntu server
2) Update the system repository and install OpenJDK
3) Download and install Jenkins
4) Access the Jenkins WebAdmin and complete the post-installation setup
5) Conclusion

Step 1: Open an SSH connection to your Ubuntu Server.

To open an SSH connection to your Ubuntu server using an SSH client such as Putty, you need to know the IP address of your server. You can run the following command to check the IP address:

sudo ip addr list | grep inet 

Once you obtain your server IP address, you can proceed to open the SSH connection. If you are using the macOS terminal app, you can open the connection by running the command:

 ssh server_username@ip_address_of_server 

Step 2: Update the system repository and install OpenJDK

The next step is to update the system and install OpenJDK. Updating your system is important as this will update outdated packages and install security patches and improvements. You can install updates on your Ubuntu server by running the command:
 sudo apt update && sudo apt upgrade 
Once the update process completes, restart the server and run the following commands to install OpenJDK:
sudo apt install default-jre
sudo apt install default-jdk

Step 3: Download and install Jenkins

To ensure that you get the latest version of Jenkins with all its features and bug fixes, it is recommended to install it using the project-maintained repository instead of the default Ubuntu repository. Follow the steps below to add the Jenkins repository to your Ubuntu system:
1. Start by importing the GPG key. This key verifies package integrity, but there will be no output. Run the following command:

 curl -fsSL https://pkg.jenkins.io/debian-stable/jenkins.io.key | sudo tee /usr/share/keyrings/jenkins-keyring.asc > /dev/null

2. Add the Jenkins software repository to the source list and provide the authentication key:

 echo deb [signed-by=/usr/share/keyrings/jenkins-keyring.asc] https://pkg.jenkins.io/debian-stable binary/ | sudo tee /etc/apt/sources.list.d/jenkins.list > /dev/null

This command adds the Long Term Support (LTS) stable release to the sources list. Finally run the following commands to update the system repository and install Jenkins:

sudo apt update
sudo apt install jenkins

Run the following command to configure Jenkins to start at system boot:

systemctl enable jenkins

Ensure Jenkins is installed and running with the command: sudo systemctl status jenkins. Look for a green label that indicates the service is active and running. Exit the status screen by simply press Ctrl+Z on your keyboard. To allow Jenkins to communicate, you need to set up the default UFW firewall. Open port 8080 by running the following commands:

sudo ufw allow 8080
sudo ufw status

If you’re using a different firewall application, please follow its specific instructions to allow traffic on port 8080. If you haven’t configured the UFW firewall yet, it may display as inactive. Enable UFW by running:

sudo ufw enable
Finally you can verify the port Jenkins is listening on by running the command:
sudo lsof -i -P -n | grep LISTEN

Step 4: Access the Jenkins WebAdmin and complete the post-installation setup

To set up Jenkins and start using it, follow the steps below:

Open a web browser and enter your server’s IP address in the address bar. Use the following format:
http://ip_address_or_domain:8080.

Make sure to use the actual IP address or domain name for the server on which you’re using Jenkins. For example, if you’re running Jenkins locally, use localhost, and the IP address will be:
http://localhost:8080.

When the Jenkins Getting Started page loads, run the following command to get the default administrator password for Jenkins:

cat /var/lib/jenkins/secrets/initialPassword

Copy the returned password and paste it on the “Administrator password” field on the Jenkins post installation wizard. Click “Continue” and click “Install Suggested plugins”. Once the plugin installation completes, set your own secure Administrator password, email, first name and last name and click “Save and Continue”

Enter the URL used to access Jenkins on the Jenkins URL field. You can simply copy the URL on the address bar and paste it on the Jenkins URL field. Click Save and Finish and click Start Using Jenkins. You should see the Jenkins dashboard and start using the software utility for your CI/CD needs.

Conclusion

In this tutorial, we covered the steps needed to install and configure Jenkins on Ubuntu 22.04 LTS. By following these steps, you can easily set up a powerful CI/CD pipeline that will automate your build, testing, and deployment processes. This can save you significant time and effort, allowing you to focus on other aspects of your development work.

Here are some key takeaways from this tutorial:

1. Jenkins is an open-source automation server that is free to use.
2. Jenkins can be used to automate the build, testing, and deployment of your applications.
3. Jenkins is highly extensible and has a wide variety of plugins available.
4. Jenkins is relatively easy to install and configure.

Now that you have Jenkins up and running, you can start creating pipelines for your projects. You can find more information about Jenkins and how to use it on the official Jenkins website: https://jenkins.io.

We hope this tutorial has been helpful!

Scroll to Top