How to Install Jenkins on CentOS.
Below are the steps to install Jenkins on your CentOS system.
Step 1: Jenkins is java application, first install java in your CentOS Server.
sudo yum install java-1.8.0-openjdk-devel.
Note: When we published this blog Java 8 is recommended, Java 9 and Java 10 are not supported.
Step 2: Download Jenkins.
Type URL : https://www.jenkins.io/download/ on your browser and click on Red Hat/Fedora/CentOS option.
Run the following command:
sudo wget -O /etc/yum.repos.d/jenkins.repo https://pkg.jenkins.io/redhat-stable/jenkins.repo
sudo rpm –import https://pkg.jenkins.io/redhat-stable/jenkins.io.key
If you’ve previously imported the key from Jenkins, the “rpm –import” will fail because you already have a key. Please ignore that and move on.
With that set up, the Jenkins package can be installed with:
yum install jenkins
Jenkins installation completed.
Step 3: Start the Jenkins.
Command to start jenkins:
service jenkins start
Command to check jenkins status:
service jenkins status
Step 4: Access jenkins UI
Type http://<public ip>:8080
Login to server where jenkins is installed and cat the file /var/lib/jenkins/secrets/initialAdminPassword file and give copy past the initialAdminPassword
After entering password, select plugins option(install suggested plugins are recommended)
Installed and login to jenkins successfully.
Note: Jenkins by default it will run on 8080 port. recommended to change the port.
To change port: Login to server where jenkins is running and vi /etc/sysconfig/jenkins and change 8080 port.