2017년 7월 25일 화요일

How to install & configure Jenkins on CentOS/RHEL/Fedora/openSUSE

http://www.2daygeek.com/how-to-install-configure-jenkins-on-centos-rhel-fedora-opensuse/

How to install & configure Jenkins on CentOS/RHEL/Fedora/openSUSE

Jenkins is an open source continuous integration tool written in Java. The project was forked from Hudson after a dispute with Oracle. It provides 1000 of plugins to support building, deploying and automating any project. Many users calling Jenkins as a open source automation server.

Jenkins is a self-contained Java-based program, ready to run out-of-the-box, with packages for Windows, Mac OS X and other Unix-like operating systems.

Jenkins can be easily set up and configured through easy to use web interface. Jenkins can easily distribute work across multiple machines, helping drive builds, tests and deployments across multiple platforms faster and can be extended via its plugin architecture.

Prerequisites for Jenkins

Jenkins is running on servlet container such as Apache Tomcat. It’s required JAVA and Jenkins team suggested to install openJDK.



Install Jenkins on CentOS/RHEL

We can easily install Jenkins on CentOS/RHEL system by adding Jenkins official repository.

[Install Jenkins stable]
$ sudo wget -O /etc/yum.repos.d/jenkins.repo http://pkg.jenkins.io/redhat-stable/jenkins.repo
$ sudo rpm --import http://pkg.jenkins.io/redhat-stable/jenkins.io.key
$ sudo yum install jenkins

Install latest Jenkins (Unstable)

$ sudo wget -O /etc/yum.repos.d/jenkins.repo http://pkg.jenkins.io/redhat/jenkins.repo
$ sudo rpm --import http://pkg.jenkins.io/redhat/jenkins.io.key
$ sudo yum install jenkins

Install Jenkins on openSUSE

We can easily install Jenkins on openSUSE system by adding Jenkins official repository.

[Install Jenkins stable]
$ sudo zypper addrepo -f http://pkg.jenkins.io/opensuse-stable/ jenkins
$ sudo zypper install jenkins

Install latest Jenkins (Unstable)

$ sudo zypper addrepo -f http://pkg.jenkins.io/opensuse/ jenkins
$ sudo zypper install jenkins

Install Jenkins on Fedora
We can easily install Jenkins on Fedora system from distirbution official repository.

$ sudo dnf install jenkins

Start and Enable Jenkins Service

Run the following systemd & SysVinit commands to start and enable the jenkins service.
[Start, Enable & check the Status of Jenkins service on systemd system]
$ sudo systemctl start jenkins
$ sudo systemctl enable jenkins
$ sudo systemctl status jenkins

[Start, Enable & check the Status of Jenkins service on SysVinit system]

$ sudo service jenkins start
$ sudo service jenkins status
$ sudo chkconfig jenkins on

Allow the ports on firewall

Allow the required ports on firewall for public access.

[Open a Port on CentOS/RHEL 7 & Fedora]
firewall-cmd --zone=public --add-port=8080/tcp --permanent
firewall-cmd --zone=public --add-service=http --permanent
firewall-cmd --reload

Open a Port on CentOS/RHEL 6
$ sudo iptables -I INPUT -p tcp -m tcp --dport 80 -j ACCEPT
$ sudo iptables -I INPUT -p tcp -m tcp --dport 8080 -j ACCEPT
$ sudo service iptables save

Access the Jenkins Web portal
Open your web browser and navigate to http://localhost:8080 or http://your-server-ip-address:8080 or http://127.0.0.1:8080

Get the initial setup password by navigating to below location and past it on the above text box, then hit continue button.
$ sudo more /var/lib/jenkins/secrets/initalAdminPassword
root's password:
**********************

Hit Install Suggested Plugins button to install list of additional plugins which will extend jenkins with additional features to support many different needs.

Plugins installation under process.

Create first Admin account, then hit save and finish button.

Jenkins successfully installed and ready to configure your project. Hit Start using Jenkins button to move next.

Here is the Jenkisn Home Page, you can create your first project and enjoy the features.