Friday, 27 April 2018

Jenkins configuration steps on CentOS/RHEL 7


Installing Jenkins on CentOS/RHEL 7

the default JENKINS_HOME directory will be in /var/lib/jenkins.


[root@sankar-devops ~]#  wget -O /etc/yum.repos.d/jenkins.repo http://pkg.jenkins-ci.org/redhat/jenkins.repo
--2018-04-24 06:49:09--  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   

2018-04-24 06:49:10 (3.82 MB/s) - ‘/etc/yum.repos.d/jenkins.repo’ saved [71/71]

[root@sankar-devops ~]# rpm --import https://jenkins-ci.org/redhat/jenkins-ci.org.key
[root@sankar-devops ~]# yum install jenkins
Loaded plugins: fastestmirror, langpacks
base                                                                                                           | 3.6 kB  00:00:00   
extras                                                                                                         | 3.4 kB  00:00:00   
jenkins                                                                                                        | 2.9 kB  00:00:00   
updates                                                                                                        | 3.4 kB  00:00:00   
jenkins/primary_db                                                                                             | 110 kB  00:00:02   
Loading mirror speeds from cached hostfile
 * base: centos.excellmedia.net
 * extras: centos.excellmedia.net
 * updates: centos.excellmedia.net
Resolving Dependencies
--> Running transaction check
---> Package jenkins.noarch 0:2.118-1.1 will be installed
--> Finished Dependency Resolution

Dependencies Resolved

======================================================================================================================================
 Package                        Arch                          Version                            Repository                      Size
======================================================================================================================================
Installing:
 jenkins                        noarch                        2.118-1.1                          jenkins                         71 M

Transaction Summary
======================================================================================================================================
Install  1 Package

Total download size: 71 M
Installed size: 71 M
Is this ok [y/d/N]: y
Downloading packages:
jenkins-2.118-1.1.noarch.rpm                                                                                   |  71 MB  00:02:37   
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
  Installing : jenkins-2.118-1.1.noarch                                                                                           1/1
  Verifying  : jenkins-2.118-1.1.noarch                                                                                           1/1

Installed:
  jenkins.noarch 0:2.118-1.1                                                                                                       

Complete!
[root@sankar-devops ~]#

[root@sankar-devops logs]# systemctl daemon-reload

[root@sankar-devops logs]# systemctl status jenkins
● jenkins.service - LSB: Jenkins Automation Server
   Loaded: loaded (/etc/rc.d/init.d/jenkins; bad; vendor preset: disabled)
   Active: inactive (dead)
     Docs: man:systemd-sysv-generator(8)

[root@sankar-devops logs]# systemctl start jenkins
[root@sankar-devops logs]# systemctl status jenkins
● jenkins.service - LSB: Jenkins Automation Server
   Loaded: loaded (/etc/rc.d/init.d/jenkins; bad; vendor preset: disabled)
   Active: active (running) since Tue 2018-04-24 06:57:16 IST; 10s ago
     Docs: man:systemd-sysv-generator(8)
  Process: 12112 ExecStart=/etc/rc.d/init.d/jenkins start (code=exited, status=0/SUCCESS)
   CGroup: /system.slice/jenkins.service
           â””─12130 /etc/alternatives/java -Dcom.sun.akuma.Daemon=daemonized -Djava.awt.headless=true -DJENKINS_HOME=/var/lib/jenkin...

Apr 24 06:57:15 sankar-devops systemd[1]: Starting LSB: Jenkins Automation Server...
Apr 24 06:57:15 sankar-devops runuser[12115]: pam_unix(runuser:session): session opened for user jenkins by (uid=0)
Apr 24 06:57:16 sankar-devops jenkins[12112]: Starting Jenkins [  OK  ]
Apr 24 06:57:16 sankar-devops systemd[1]: Started LSB: Jenkins Automation Server.
[root@sankar-devops logs]#


just try it in browser : like localhost:8080



How to change the default port for Jenkins on Linux

by default tomcat run port 8080, if we install jenkins in same machine, it's also used same port.

temperately we need to stop tomcat while configuring the Jenkins.

after installed jenkins we need to change the port and up the tomcat as well.


[root@sankar-devops logs]# vi /etc/sysconfig/jenkins

# Port Jenkins is listening on.
# Set to -1 to disable
#
JENKINS_PORT="8090"  //by default its 8080 

:wq!

[root@sankar-devops logs]# systemctl daemon-reload
[root@sankar-devops logs]# systemctl status jenkins
● jenkins.service - LSB: Jenkins Automation Server
   Loaded: loaded (/etc/rc.d/init.d/jenkins; bad; vendor preset: disabled)
   Active: active (running) since Tue 2018-04-24 06:57:16 IST; 34min ago
     Docs: man:systemd-sysv-generator(8)
   CGroup: /system.slice/jenkins.service
           â””─12130 /etc/alternatives/java -Dcom.sun.akuma.Daemon=daemonized -Djava.awt.headless=true -DJENKINS_HOME=/var/lib/jenkin...

Apr 24 06:57:15 sankar-devops systemd[1]: Starting LSB: Jenkins Automation Server...
Apr 24 06:57:15 sankar-devops runuser[12115]: pam_unix(runuser:session): session opened for user jenkins by (uid=0)
Apr 24 06:57:16 sankar-devops jenkins[12112]: Starting Jenkins [  OK  ]
Apr 24 06:57:16 sankar-devops systemd[1]: Started LSB: Jenkins Automation Server.

[root@sankar-devops logs]# systemctl restart jenkins

[root@sankar-devops logs]# systemctl status jenkins
● jenkins.service - LSB: Jenkins Automation Server
   Loaded: loaded (/etc/rc.d/init.d/jenkins; bad; vendor preset: disabled)
   Active: active (running) since Tue 2018-04-24 07:32:14 IST; 2s ago
     Docs: man:systemd-sysv-generator(8)
  Process: 13176 ExecStop=/etc/rc.d/init.d/jenkins stop (code=exited, status=0/SUCCESS)
  Process: 13191 ExecStart=/etc/rc.d/init.d/jenkins start (code=exited, status=0/SUCCESS)
   CGroup: /system.slice/jenkins.service
           â””─13207 /etc/alternatives/java -Dcom.sun.akuma.Daemon=daemonized -Djava.awt.headless=true -DJENKINS_HOME=/var/lib/jenkin...

Apr 24 07:32:12 sankar-devops systemd[1]: Starting LSB: Jenkins Automation Server...
Apr 24 07:32:12 sankar-devops runuser[13193]: pam_unix(runuser:session): session opened for user jenkins by (uid=0)
Apr 24 07:32:14 sankar-devops jenkins[13191]: Starting Jenkins [  OK  ]
Apr 24 07:32:14 sankar-devops systemd[1]: Started LSB: Jenkins Automation Server.
[root@sankar-devops logs]#

[root@sankar-devops logs]# netstat -ntlup |grep 8090
       
tcp6       0      0 :::8090                 :::*                    LISTEN      13207/java       
   
[root@sankar-devops logs]#

try it in browser like : localhost:8090


how to check jenkins version on linux:

[root@sankar-devops jenkins]# cat /var/lib/jenkins/config.xml |grep version
<?xml version='1.1' encoding='UTF-8'?>
  <version>2.118</version>
[root@sankar-devops jenkins]# 

1 comment: