Installing Jenkins
The easies way to install jenkins is following the instructions in their official page
sudo wget -O /etc/yum.repos.d/jenkins.repo http://pkg.jenkins-ci.org/redhat/jenkins.repo
sudo rpm --import http://pkg.jenkins-ci.org/redhat/jenkins-ci.org.key
sudo yum install jenkins
Jenkins require java installed, to do so check Installing java in CentOS
Configuring Jenkins
Changing the default port when Jenkins is installed as a service
The script that manages Jenkins on the system is located in /etc/init.d/jenkins
So to change the default port, 8080, the easiest way is to replace the value of the variable HTTP_PORT
in the file /etc/sysconfig/jenkins
. This can be done using the following command as super user, where NEW_PORT is the value of the port you want to asign
sed -i s/JENKINS_PORT=\"8080\"/JENKINS_PORT=\"{NEW_PORT}\"/g /etc/sysconfig/jenkins
Then you just need to restart the service
/etc/init.d/jenkins restart #service jenkins restart #will also works
Setting jenkins to start when the server starts
chkconfig jenkins on
Opening Jenkins ports
CentOS 7 has a new firewall application, for previous versions the service is called iptables.
firewall-cmd --permanent --zone=public --add-port={NEW_PORT}/tcp
firewall-cmd --reload