How to Install Jenkins on CentOS 7

r00t October 2, 2017

Install Jenkins on CentOS 7

In this tutorial we’ll learn how to install Jenkins on CentOS 7. We will also install and configure its prerequisites. Jenkins is absolutely free and open source CI (Continuous Integration) tool and its code has been written in Java. It provides the characteristic of proceeds build and setup or in other words, we could say it is an automation server. Jenkins is used where continues to build and integration is going on for applications development.

I recommend to use a minimal Ubuntu server setup as a basis for the tutorial, that can be a virtual or a root server image with an CentOS 7 minimal install from a web hosting company or you use our minimal server tutorial to install a server from scratch.

Install Jenkins on CentOS 7

Step 1. First, ensure your system is fully up-to-date by running the following:

yum -y update

Step 2. Installing Java.

We need to JAVA 8 installed & configured on the server where we will be installing jenkins:

sudo yum install java-1.8.0-openjdk.x86_64

After the installation, confirm it by using the following command:

java -version

In order to help Java-based applications locate the Java virtual machine properly, you need to set two environment variables:

sudo cp /etc/profile /etc/profile_backup
echo 'export JAVA_HOME=/usr/lib/jvm/jre-1.8.0-openjdk' | sudo tee -a /etc/profile
echo 'export JRE_HOME=/usr/lib/jvm/jre' | sudo tee -a /etc/profile
source /etc/profile

Finally, you can print them for review:

echo $JAVA_HOME
echo $JRE_HOME

Step 3. Installing Jenkins.

To install the latest stable version of Jenkins you can use the official YUM repo:

cd ~
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
sudo yum install jenkins

Run the following systemctl commands to start and enable the jenkins service:

systemctl start jenkins
systemctl enable jenkins

After the installation, we need to allow port 80 & 8080 on the firewalld of the system. Run:

firewall-cmd –zone=public –add-port=8080/tcp –permanent
firewall-cmd –zone=public –add-service=http –permanent
firewall-cmd –reload

Step 4. Access the Jenkins Web portal.

Now, access the Jenkins using the below address from your web browser:

http://your_server_IP_or_domain_name:8080

Congratulation’s! You have successfully install and configured Jenkins on your CentOS 7 server. Thanks for using this tutorial for installing Jenkins on CentOS 7 system.

The Tags:

Leave a Comment

Comments are closed.