Install Jenkins on CentOS 7
Introduction
This article is to guide how to setup Jenkins on CentOS 7. All below commands will be run with root privilege.
Installing
Step 1: Update CentOS 7 system
- You need to update your system to get lastes stable packages, then reboot.
yum install epel-release -y
yum update
reboot
- Stop SELinux
sed -i "s/SELINUX=enforcing/SELINUX=disabled/g" /etc/selinux/config
reboot
Step 2: Install Java 1.8
- Before you can install Jenkins, you need to setup a Java virtual machine on your system. Here, let’s install the latest OpenJDK Runtime Environment 1.8.0 using YUM:
yum install java-1.8.0-openjdk.x86_64 -y
- Add Java environment including JAVA_HOME and JRE_HOME.
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
- Verify the two variables.
echo $JAVA_HOME
echo $JRE_HOME
Step 3: Install Jenkins
Use the official YUM repo to install the latest stable version of Jenkins, which is 1.651.2 at the time of writing:
cd ~
yum install -y wget
wget -O /etc/yum.repos.d/jenkins.repo https://pkg.jenkins.io/redhat-stable/jenkins.repo
rpm --import https://pkg.jenkins.io/redhat-stable/jenkins.io.key
yum install jenkins -y
- Start Jenkins and set it to run at boot time:
systemctl start jenkins.service
systemctl enable jenkins.service
- Because Firewalld is running, to allow users can access to Jenkins Web, you need to open 8080 on firewalld:
firewall-cmd --zone=public --permanent --add-port=8080/tcp
firewall-cmd --reload
- Now, you can test by accessing the link: http://
:8080
References
[1] https://www.vultr.com/docs/how-to-install-jenkins-on-centos-7