Are you looking for an easy guide on to how to install Jenkins?
The step-by-step guide on this page demonstrates you how to install Jenkins on Ubuntu 22.04 or Ubuntu 20.04.
Jenkins is an open-source automation server widely used for continuous integration and continuous deployment (CI/CD) in software development. With its extensive plugin ecosystem and user-friendly interface, Jenkins simplifies the process of building, testing, and deploying code.
- Pre-Installed Ubuntu 22.04 or 20.04
- User with sudo privileges
- Internet Connectivity
Without much fuss , let’s deep dive into Jenkins installation steps on Ubuntu 22.04 or 20.04
1) Install Java Development Kit (JDK)
Being a Java application, Jenkins requires Java 8 and later versions to run without any issues. To check if Java is installed on your system, run the command:
$ java --version
If Java is not installed, you will get the following output.
To install Java on your system, execute the command:
$ sudo apt install -y openjdk-17-jre-headless
After the installation, once again verify that Java is installed:
$ java --version
Perfect! We now have OpenJDK installed. We can now proceed.
2) Install Jenkins via its official repository
With Java installed, we can now proceed to install Jenkins. The second step is to import the Jenkins GPG key from Jenkins repository as shown:
$ curl -fsSL https://pkg.jenkins.io/debian-stable/jenkins.io-2023.key | sudo tee \ /usr/share/keyrings/jenkins-keyring.asc > /dev/null
$ 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
Next, update the system’s package list.
$ sudo apt update
And install Jenkins as follows.
$ sudo apt install -y jenkins
Once the installation is complete, Jenkins should start automatically. To confirm this, run the command:
$ systemctl status jenkins
If by any chance Jenkins is not running, execute the following command to start it.
$ sudo systemctl start jenkins
3) Configure Firewall Rules for Jenkins
As we have seen, Jenkins natively listens on port 8080, and if you have installed Jenkins on a server with UFW enabled, you need to open that port to allow traffic.
To enable firewall on Ubuntu 22.04 / 20.04 LTS run,
$ sudo ufw enable
To open port 8080 on ufw firewall, run the command:
$ sudo ufw allow 8080/tcp
Then reload the firewall to effect the changes.
$ sudo ufw reload
To confirm that port 8080 is open on the firewall, execute the command:
$ sudo ufw status
From the output, we can clearly see that Port 8080 has been opened on the system.
4) Setup Jenkins with Web Interface
We are almost done now. The only thing remaining is to set up Jenkins using web interface. So, head over to the URL bar and browse your server’s address as shown:
To check your server’s IP address, use the ip command.
You will get the page similar to what we have below prompting you to provide the Administrator’s password. As per the instructions, the password is located in the file:
To view the password, use the cat command as shown:
$ sudo cat /var/lib/jenkins/secrets/initialAdminPassword
Copy the password and paste it in the text field shown and click the “Continue” button.
In the next step, select ‘Install suggested plugin‘ for simplicity’s sake.
Thereafter, the installation of the necessary plugin required by Jenkins will commence.
When the installation of plugins is complete, the installer will take you to the next section where you will be required to create an Admin user and click on the ‘Save and Continue’ button.
The next step will populate the default URL for your Jenkin’s instance. No action is required, simply click ‘Save and Finish’.
Finally, click on the ‘Start using Jenkins’ button to gain access to Jenkins.
This ushers you to Jenkin’s dashboard as shown.
In this guide, we’ve outlined the step-by-step process to install Jenkins on Ubuntu 22.04 or 20.04. Jenkins is a powerful tool that can significantly improve your development workflow by automating repetitive tasks and streamlining your CI/CD process. Explore the vast array of plugins and integrations Jenkins offers to customize your automation server according to your project’s requirements.
Also Read : How to Setup Jenkins on CentOS 8 / RHEL 8