How to Install Jenkins: A Step-by-Step Guide#

Jump to Jenkins Certification and study guide

Jenkins is an open-source automation tool widely used for Continuous Integration and Continuous Deployment (CI/CD). It’s easy to set up and customize for your development workflows. Here’s a step-by-step guide to installing Jenkins on a server. Prerequisites

Operating System: Ensure your server runs a supported OS (Linux, Windows, macOS).
Java: Jenkins requires Java. Install a supported version of OpenJDK or Oracle JDK (recommended versions vary with Jenkins; check their documentation).
Hardware: At least 1 GB RAM and 50 GB storage (more for larger projects).

Step 1: Update Your System#

Before installing Jenkins, update your system packages. For Debian/Ubuntu:

sudo apt update && sudo apt upgrade -y

For CentOS/Red Hat:

sudo yum update -y

Step 2: Install Java#

For Debian/Ubuntu:

sudo apt install openjdk-11-jdk -y

For CentOS/Red Hat:

sudo yum install java-11-openjdk-devel -y

Verify Java installation:

java -version

Step 3: Add the Jenkins Repository#

For Debian/Ubuntu:

Add the Jenkins key:

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

Add the repository:

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

For CentOS/Red Hat:

Import the Jenkins repository key:

sudo rpm --import https://pkg.jenkins.io/redhat-stable/jenkins.io.key

Add the repository:

sudo curl -o /etc/yum.repos.d/jenkins.repo \
https://pkg.jenkins.io/redhat-stable/jenkins.repo

Step 4: Install Jenkins#

For Debian/Ubuntu:

sudo apt update
sudo apt install jenkins -y

For CentOS/Red Hat:

sudo yum install jenkins -y

Step 5: Start and Enable Jenkins#

For Systemd (All OS):

sudo systemctl start jenkins
sudo systemctl enable jenkins

Check Jenkins status:

sudo systemctl status jenkins

Step 6: Configure Firewall (Optional)#

If you use a firewall, open port 8080 (default for Jenkins): For Debian/Ubuntu:

sudo ufw allow 8080
sudo ufw reload

For CentOS/Red Hat:

sudo firewall-cmd --permanent --add-port=8080/tcp
sudo firewall-cmd --reload

Step 7: Access Jenkins#

Open a web browser and navigate to:

http://<your-server-ip>:8080

Unlock Jenkins:

Retrieve the initial admin password:

sudo cat /var/lib/jenkins/secrets/initialAdminPassword

Enter the password on the Jenkins setup page. Install recommended plugins or customize based on your needs. Create an admin user and complete the setup.

Conclusion

Congratulations! You’ve successfully installed Jenkins on your server. Now, you can begin setting up pipelines to automate your builds, tests, and deployments. To enhance functionality, explore the extensive range of plugins available in Jenkins: Plugins Index

Jenkins Certification#

Jenkins Certification Information: Certified Jenkins Engineer (CJE) Certification

Jenkins Certification Study Guide: Certified Jenkins Engineer (CJE)