Saturday 11 May 2019

How to Install Jenkins on Cent OS 7



Jenkins is a popular free and open source, Java-based automation tool that provide continues integration and continuous delivery.  Its code is written in Java. It provides the feature of continues development, deployment, and automation.
This tutorial will guide you the steps of installing Jenkins on a CentOS 7 system using the official Jenkins repository.

Step 1: Install java binary from the article How to install Java8/jdk1.8 in Centos7 using YUM.

Step 2: Run the following command to download Jenkins repo from official site and Setup Jenkins repository. If wget command not install follow the article How to resolve wget: command not found

[root@linuxcnf ~]# wget -O /etc/yum.repos.d/jenkins.repo http://pkg.jenkins-ci.org/redhat/jenkins.repo
--2019-05-11 13:31:31--  http://pkg.jenkins-ci.org/redhat/jenkins.repo
Resolving pkg.jenkins-ci.org (pkg.jenkins-ci.org)... 52.202.51.185
Connecting to pkg.jenkins-ci.org (pkg.jenkins-ci.org)|52.202.51.185|:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 71
Saving to: ‘/etc/yum.repos.d/jenkins.repo’

100%[==============================================================================================================================>] 71          --.-K/s   in 0s

2019-05-11 13:31:33 (5.69 MB/s) - ‘/etc/yum.repos.d/jenkins.repo’ saved [71/71]

[root@linuxcnf ~]#

Then, import the verification key using the following command:

[root@linuxcnf ~]# rpm --import https://jenkins-ci.org/redhat/jenkins-ci.org.key
[root@linuxcnf ~]#
  
Step 3: Install Jenkins packages by running the following command:

[root@linuxcnf ~]# yum install jenkins
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
 * base: centos.mirrors.estointernet.in
 * extras: mirror.0x.sg
 * updates: mirror.0x.sg
jenkins                                                                    | 2.9 kB  00:00:00
jenkins/primary_db                                                     | 128 kB  00:00:02
Resolving Dependencies
--> Running transaction check
---> Package jenkins.noarch 0:2.176-1.1 will be installed
--> Finished Dependency Resolution
................
Installed:
  jenkins.noarch 0:2.176-1.1

Complete!
[root@linuxcnf ~]#

Step 4: Configure firewall to allow access Jenkins services:

[root@linuxcnf ~]# firewall-cmd --zone=public --add-port=8080/tcp --permanent
success
[root@linuxcnf ~]# firewall-cmd --zone=public --add-service=http --permanent
success
[root@linuxcnf ~]# firewall-cmd --reload
success
[root@linuxcnf ~]#
  
Step 5: Finally, Start and enable Jenkins services by running the following command:

[root@linuxcnf ~]# systemctl enable jenkins.service
jenkins.service is not a native service, redirecting to /sbin/chkconfig.
Executing /sbin/chkconfig jenkins on
[root@linuxcnf ~]#
[root@linuxcnf ~]# systemctl start jenkins.service
[root@linuxcnf ~]#

Step 6: Verify the installation by accessing the Jenkins web portal. Access the below URL on any browser:

http://<Server IP/Hostname>:8080

You can find admin password in file /var/lib/jenkins/secrets/initialAdminPassword.

[root@linuxcnf ~]# cat /var/lib/jenkins/secrets/initialAdminPassword
f5369d2d61a145698d29b7447d811bfd
[root@linuxcnf ~]#

Installation is done!!! Now you can configure Jenkins accordingly.

No comments:

Post a Comment