Jenkins is an open-source automation server that is used to automate various stages of the software development process such as building, testing, and deploying applications. It provides a web-based graphical user interface (GUI) that allows users to configure and manage Jenkins jobs, pipelines, and plugins.
In this article, we will discuss how to install Jenkins on a Linux machine.
Prerequisites Before we proceed with the installation of Jenkins, we need to make sure that our system meets the following requirements:
- A Linux machine (Ubuntu, Debian, CentOS, RedHat, etc.)
- Java 11 or 17 version installed on the system
Automate your software development process with Jenkins — the open-source automation server that simplifies building, testing, and deploying applications.
You can learn about Jenkins from this Certification Training Course -
Jenkins Masterclass: Continuous Integration and Deployment
Installation Steps
Step 1: Update System Packages
Before installing Jenkins, we need to make sure that our system is up to date. To update the system packages, we can run the following command:
sudo apt update && sudo apt upgrade
Step 2: Install Java
As Jenkins is a Java-based application, we need to install Java on our system. To install Java, we can run the following command:
sudo apt install openjdk-11-jdk
Step 3: Add Jenkins Repository Key
Next, we need to add the Jenkins repository key to our system. To add the Jenkins repository key, we can run the following command:
wget -q -O - https://pkg.jenkins.io/debian-stable/jenkins.io.key | sudo apt-key add -
Step 4: Add Jenkins Repository to Sources List
After adding the Jenkins repository key, we need to add the Jenkins repository to our system’s sources list. To add the Jenkins repository to our system’s sources list, we can run the following command:
sudo sh -c 'echo deb https://pkg.jenkins.io/debian-stable binary/ > /etc/apt/sources.list.d/jenkins.list'
Step 5: Install Jenkins
After adding the Jenkins repository to our system’s sources list, we can install Jenkins by running the following command:
sudo apt update && sudo apt install jenkins
This command will install Jenkins and its dependencies on our system.
Step 6: Start Jenkins Service
Once Jenkins is installed, we can start the Jenkins service by running the following command:
sudo systemctl start jenkins
We can also enable the Jenkins service to start automatically on system boot by running the following command:
sudo systemctl enable jenkins
Step 7: Access Jenkins Web Interface
After starting the Jenkins service, we can access the Jenkins web interface by navigating to http://<your-server-IP>:8080 in a web browser.
On the Jenkins web interface, we will be prompted to enter the initial admin password. The initial admin password is stored in the /var/lib/jenkins/secrets/initialAdminPassword file. We can retrieve the initial admin password by running the following command:
sudo cat /var/lib/jenkins/secrets/initialAdminPassword
Once we have entered the initial admin password, we can follow the on-screen instructions to complete the Jenkins installation.
Conclusion In this article, we discussed the steps to install Jenkins on a Linux machine. We also discussed the prerequisites that need to be fulfilled before installing Jenkins. By following the steps outlined in this article, we can successfully install Jenkins and start using it to automate various stages of our software development process.