Jenkins Installation on Red Hat distributions

On RPM-based distributions, such as Red Hat, CentOS, Fedora etc.. you can install Jenkins through yum.

Prerequisites:

Jenkins requires Java in order to run. To install the Open Java Development Kit (OpenJDK) run the following:

[root@jenkins-server ~]# yum install java -y
[root@jenkins-server ~]# java -version
openjdk version "1.8.0_161"
OpenJDK Runtime Environment (build 1.8.0_161-b14)
OpenJDK 64-Bit Server VM (build 25.161-b14, mixed mode)
[root@jenkins-server ~]#

Jenkins Installation :

Step 1: Add the Jenkins repository to the yum repos.

[root@jenkins-server ~]# wget -O /etc/yum.repos.d/jenkins.repo http://pkg.jenkins-ci.org/redhat/jenkins.repo
--2018-03-24 08:52:47-- 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-03-24 08:52:51 (13.2 MB/s) - ‘/etc/yum.repos.d/jenkins.repo’ saved [71/71]

[root@jenkins-server ~]#

You can install stable version from below:

wget -O /etc/yum.repos.d/jenkins.repo http://pkg.jenkins-ci.org/redhat-stable/jenkins.repo

Step 2: Add Jenkins key to rpm

[root@jenkins-server ~]# rpm --import https://jenkins-ci.org/redhat/jenkins-ci.org.key
[root@jenkins-server ~]#

Step 3: Run the following command to install Jenkins.

[root@jenkins-server ~]# yum install jenkins -y

Step 4: Restart jenkins service once installation got completed.

[root@jenkins-server ~]# 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@jenkins-server ~]# 
[root@jenkins-server ~]# systemctl restart jenkins
[root@jenkins-server ~]# 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 Sat 2018-03-24 09:04:51 UTC; 3s ago
 Docs: man:systemd-sysv-generator(8)
 Process: 1192 ExecStart=/etc/rc.d/init.d/jenkins start (code=exited, status=0/SUCCESS)
 CGroup: /system.slice/jenkins.service
 └─1211 /etc/alternatives/java -Dcom.sun.akuma.Daemon=daemonized -Djava.awt.headless=true -DJENKINS_HOME=/var/lib/jenkins -jar /usr/lib/jenkins/jenkins...

Mar 24 09:04:51 jenkins-server systemd[1]: Starting LSB: Jenkins Automation Server...
Mar 24 09:04:51 jenkins-server runuser[1197]: pam_unix(runuser:session): session opened for user jenkins by (uid=0)
Mar 24 09:04:51 jenkins-server jenkins[1192]: Starting Jenkins [ OK ]
Mar 24 09:04:51 jenkins-server systemd[1]: Started LSB: Jenkins Automation Server.
[root@jenkins-server ~]#

Step 5: Enable jenkins service to start on reboot

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

Now, you can access Jenkins with below url.

http://your-IP-Address:8080/

It will ask for Administrator password to unlock Jenkins at first time. Run following to get password.

[root@jenkins-server ~]# cat /var/lib/jenkins/secrets/initialAdminPassword
29f07f8c1cf440c398215072061a2288
[root@jenkins-server ~]#

unlock-jenkins.PNG

Copy paste the password and click on Continue. In next step, click on “Install suggested plugins”.

select-plugins-gettingstarted

plugins-gettingstarted.PNG

Once plugins installed successfully, enter user account details and click Save and Finish button.

account-setup-gettingstarted.PNG

Now Jenkins is ready to use. Click on Start using Jenkins. It will take you to Jenkins Dashboard where you can create jobs, pipelines etc..

start-jenkins.PNG

jenkins-dashboard.PNG

Here, you create your jobs by clicking on New Item and also you can create user accounts, configure your jenkins and install/uninstall plugins etc…

Advertisements