How to install Jenkins on CentOS 7

JENKINS
      Jenkins is an open source continuous integration server. It can be used to automate all sorts of tasks related to building, testing, and deploying software.
Jenkins Logo
PREREQUISITES
  • User with sudo permission
  • CentOS 7 server instance with 2 GB RAM (recommended)
  • JDK (1.5 or above) 

 INSTALL JAVA
  •  Make sure to get the latest JDK package. Download the SE JDK RPM package
wget --no-cookies --no-check-certificate --header "Cookie:oraclelicense=accept-securebackup-cookie" "http://download.oracle.com/otn-pub/java/jdk/8u131-b11/d54c1d3a095b4ff2b6607d096fa80163/jdk-8u131-linux-x64.rpm"
  •  Install the downloaded package
sudo yum -y localinstall jdk-8u131-linux-x64.rpm 
  • Check the version of Java
  java -version
 INSTALL JENKINS 
  • Add jenkins repository
sudo wget -O /etc/yum.repos.d/jenkins.repo http://pkg.jenkins-ci.org/redhat-stable/jenkins.repo
 sudo rpm --import http://pkg.jenkins-ci.org/redhat-stable/jenkins-ci.org.key
  • Run the below yum command to install Jenkins
sudo yum install jenkins
  • Run the following systemctl commands to start and enable the jenkins service
sudo systemctl start jenkins.service
sudo systemctl enable jenkins.service
  • Once the service has started, you can check its status
sudo systemctl status jenkins.service
  • Likewise, you can stop the service
sudo systemctl stop jenkins.service
sudo systemctl restart jenkins.service
  • In order to allow the clients to access the Jenkins, you need to set inbound traffic on specified port
syntax: sudo firewall-cmd --add-service=http --permanent <port number>/tcp
sudo firewall-cmd --zone=public --permanent --add-port=8888/tcp
  • After adding the port details in firewall, you must reload your firewall
sudo firewall-cmd --reload
Now, test Jenkins by visiting the following address from your web browser
http://<your_server_ip>:8888
Now Jenkins getting started page will come, where they are asking for admin password
The admin password is created and stored in the log file “/var/log/jenkins/jenkins.log“. Run the below command to get the password.
grep -A 5 password /var/log/jenkins/jenkins.log
 Now copy that password and paste it over there

Comments