Contents...
In this article I will guide you how you can install Jenkins on a CentOS 7 machine. Jenkins is a most popular open source Continuous Integration (CI) tool which is widely used for project development, deployment and automation.
In order to facilitate visitors’ access to Jenkins, you can setup an Nginx reverse proxy for Jenkins, so visitors will no longer need to key in the port number 8080 when accessing your Jenkins application.
Prerequisites
Before doing anything, you must have:
1. You should have CentOS 7 machine.
2. Logged into your server with sudo privileges.
Follow the below steps to install Jenkins on CentOS 7 machine.
Step #1: Update CentOS 7 Machine
The Linux system administrator best practices is keeping a system up to date. Install the latest stable packages and then reboot the machine.
$ sudo yum install epel-release $ sudo yum update $ sudo reboot
Now reboot the system and login with the same sudo user.
Step #2: Install Java
You will need to install Java on your machine before installing Jenkins. Install the latest Open JDK Runtime Environment 1.8.0 using YUM command.
$ sudo yum install java-1.8.0-openjdk.x86_64
After the installation, confirm it by using the following command:
$ java -version
You will get some output like below. Above command will tell you about the Java runtime environment that you have installed.
openjdk version "1.8.0_91" OpenJDK Runtime Environment (build 1.8.0_91-b14) OpenJDK 64-Bit Server VM (build 25.91-b14, mixed mode)
In order to help Java-based applications locate the Java virtual machine properly, you need to set two environment variables:
“JAVA_HOME” and “JRE_HOME”
$ 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
That’s it, now you can print them for review:
$ echo $JAVA_HOME $ echo $JRE_HOME
Step #3: Jenkins Installation
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
Now start the Jenkins service and set it to run at boot time.
$ sudo systemctl start jenkins.service $ sudo systemctl enable jenkins.service
You will need to allow the inbound traffic on port 8080 to access the Jenkins.
$ sudo firewall-cmd --zone=public --permanent --add-port=8080/tcp $ sudo firewall-cmd --reload
Now, access the Jenkins using the below address from your web browser:
http://your_server_IP_or_domain_name:8080
In my case my server IP address is 192.168.0.109 and port is 8080.
That’s it.
If you find this tutorial helpful please share with your friends to keep it alive. For more helpful topic browse my website www.looklinux.com. To become an author at LookLinux Submit Article. Stay connected to Facebook.
Leave a Comment