Jenkins is a popularly used open-source automation server that automates the process of software developing and delivering. It is built using Java and can be installed on Ubuntu either by using Ubuntu packages or by downloading and executing its WAR(Web Application Archive) file. More specifically, this file keeps all the required data/files to run Jenkins as a complete web application on a server.
This post illustrates the complete process of installing Jenkins on Ubuntu 22.04.
How to Install, Configure, and Setup Jenkins on Ubuntu 22.04?
Jenkins makes software development a lot easier by automating many tasks, which helps developers work more efficiently.
So, go through the following steps to install Jenkins on Ubuntu 22.04 without any hassle.
Step 1: Verify Java Installation
Java installation is a prerequisite for Jenkins. Therefore, first, ensure the Java’s installation on Ubuntu by executing the below-provided command:
Here, the output snippet indicates that Java is not installed on our Ubuntu machine:
Step 2: Install Java
Install Java on Ubuntu 22.04 by executing the given command:
sudo apt install openjdk-version-jdk -y
Now, replace the version with a valid Java version to be installed on your system, such as “8” or “11”. For instance, executing the below-given command will install Java 11 accordingly:
sudo apt install openjdk-11-jdk -y
Now, execute the “java -version” command one more time to confirm the Java’s installation on Ubuntu 22.04:
The output snippet confirms the Java’s installation:
Step 3: Add Jenkins Repository
Before adding the Jenkins repository, first you need to import the GPG key which ensures the package integrity. For this purpose, write the below-provided command and hit the Enter key:
wget -p -O - https://pkg.jenkins.io/debian/jenkins.io.key | sudo apt-key add -
The output indicates that the GPG key has been imported successfully:
Next, include the Jenkins Repository by executing the following command in the terminal:
sudo sh -c 'echo deb http://pkg.jenkins.io/debian-stable binary/ > /etc/apt/sources.list.d/jenkins.list'
Step 4: Update System Repository
We have successfully completed the prerequisite steps. Now, we can proceed with the Jenkins installation on Ubuntu 22.04. However, before doing that, make sure to update the system packages:
sudo apt update
Step 5: Install Jenkins
Now, we are all set to install Jenkins on Ubuntu 22.04. We can accomplish this by running the below-given command:
sudo apt install jenkins -y
The Jenkins server has been successfully installed on Ubuntu 22.04:
How to Check Jenkins Status on Ubuntu 22.04?
To check the current status of the Jenkins Server, execute the below-provided “sudo” command:
sudo systemctl status jenkins
The below output snippet shows that Jenkins is active and in the running state:
How to Configure the Firewall for Jenkins?
Follow the below-exhibited steps to configure the firewall for Jenkins:
Step 1: Configure the Firewall
To configure the firewall for Jenkins using the UFW tool, all you need to do is activate the firewall and allow access to port 8080 for remote connections. For this, simply enter the below-provided command:
sudo ufw allow 8080
Step 2: Check UFW Status
To see the current status of the UFW, type the given command, and hit Enter:
sudo ufw status
Step 3: Activate UFW Firewall
Currently, UFW is inactive, execute the following command to activate it:
sudo ufw enable
Step 4: Verify UFW Status
Execute the below-depicted command to verify the status of the UFW:
sudo ufw status
The output demonstrates that the UFW firewall is now activated and configured to allow remote connections from anywhere on port 8080:
How to Setup Jenkins on Ubuntu 22.04?
Execute the below-provided steps to set up Jenkins on Ubuntu 22.04:
To set up Jenkins on Ubuntu 22.04, open a browser and specify the domain name or IP address followed by port 8080 in the address bar. Upon doing so, you will be navigated to the Unlock Jenkins page where you will be prompted to enter a password:
Get Administrator Password for Jenkins
Then, open the terminal and execute the below-provided “sudo” command to get the administrator password for Jenkins:
sudo cat /var/lib/jenkins/secrets/initialAdminPassword
After that, copy the obtained password from the terminal and paste it into the “Administrator Password” field which is available under the “Unlock Jenkins” page:
After providing the administrator password, hit the “Continue” button and it will lead you to the following window:
Next, click the “Install Suggested plugins” to install the plugins that facilitate the users with additional features. As a result, it will begin installing the default plugins:
Create Admin User
Specify the signup details like username, password, email address, etc., and hit the “save and continue” button:
Upon doing so, you will be navigated to the following page:
Hit the “Save and Finish” button to complete the Jenkins setup. Resultantly, the below-given window will appear on your screen:
How to Use Jenkins on Ubuntu 22.04?
Eventually, clicking on the “Start using Jenkins” button will lead you to the Jenkins Dashboard:
This is how you can install, configure, and set up Jenkins on your Ubuntu 22.04 operating system.
To install Jenkins on Ubuntu 22.04, first, install Java, add Jenkins repository, update the system repository, and then install Jenkins by executing the “sudo apt install jenkins -y” command. After that, execute the “sudo ufw allow 8080” command to configure the firewall for Jenkins.
To set up Jenkins on Ubuntu 22.04, access Jenkins by providing your domain name or IP address, unlock Jenkins by using the administrator password, and install the suggested plugins. Finally, create an admin user by following the on-screen instructions.