Introduction
Jenkins is an open-source, self-contained automation server that automates all sorts of software development tasks, such as building, testing, and deploying. A Java Runtime Environment (JRE) is required for Jenkins to run on any machine with native system packages, Docker, or even as a standalone application.
Prior to being available on the open-source project, Jenkins was developed originally by Hudson.
In this article, you will understand how to install Jenkins on Ubuntu OS.
1. Installing Java Development Kit
a. Updating the package index:
sudo apt-get update
b. Install the OpenJDK package:
sudo apt install default-jdk
c. Verifying the java installation:
java -version
Output
openjdk version "11.0.17" 2022-10-18
OpenJDK Runtime Environment (build 11.0.17+8-post-Ubuntu-1ubuntu218.04)
OpenJDK 64-Bit Server VM (build 11.0.17+8-post-Ubuntu-1ubuntu218.04, mixed mode, sharing
)
2. Installing Jenkins
It is easy to install Jenkins on Ubuntu by importing and adding GPG keys.
a. Adding repository key to your system:
wget -q -O - https://pkg.jenkins.io/debian-stable/jenkins.io.key | sudo apt-key add -
b. Add the Debian package repository address to the server’s sources.list:
sudo sh -c 'echo deb http://pkg.jenkins.io/debian-stable binary/ > /etc/apt/sources.list.d/jenkins.list'
c. Update the ca-certificates:
sudo apt install ca-certificates
d. Update the system repositories:
sudo apt update
e. Install the latest version of Jenkins
sudo apt install jenkins
3. Starting Jenkins
After the successful installation of Jenkins, the service will be started automatically. To check the status of Jenkins run the command below:
sudo systemctl status jenkins
Output
● jenkins.service - Jenkins Continuous Integration Server
Loaded: loaded (/lib/systemd/system/jenkins.service; enabled; vendor preset: enabled)
Active: active (running) since Wed 2022-12-21 09:41:24 UTC; 2h 9min ago
Main PID: 16342 (java)
Tasks: 38 (limit: 2361)
CGroup: /system.slice/jenkins.service
4. Opening the firewall
a. Jenkins runs on port 8080 by default, we need to open it with ufw:
sudo ufw allow 8080
b. To enable ufw
run the below command:
sudo ufw enable
c. Verifyufw
status to confirm the new rules have been updated:
sudo ufw status
Output
5. Setting Up Jenkins
The process for setting up a Jenkins installation is as simple as typing your domain or IP address followed by port 8080 in the browser (i.e. http://your_ip_or_domain:8080 ) and you will see the following screen.
In the terminal window, use thecat
command to display the password:
sudo cat /var/lib/jenkins/secrets/initialAdminPassword
Paste the 32-character alphanumeric password from the terminal into the Administrator password field, then click Continue.
Click the Install suggested plugins option, which will start the installation process:
Upon completion of the installation, you will be prompted to create the first administrative user. If you want, you can skip this step and continue as admin with the initial password we used above, but we'll create the user first.
Enter the desired username, password and other details. Click the 'Save and Continue' button.
You will see an Instance Configuration page that will ask you to confirm the preferred URL for your Jenkins instance. Confirm either the domain name of your server or your server’s IP address.
Click the 'Save and Finish button. You will observe a confirmation page confirming that“Jenkins is Ready!”:
Click the 'Start using Jenkins' button to navigate to the main Jenkins dashboard:
Jenkins setup is completed and you can perform all the operations in Jenkins.