How to install Jenkins on CentOS

This tutorial provides steps for installing Jenkins on CentOS

Check Java installation


[root@algo-s ~]# java --version
-bash: java: command not found


As Java is not installed, so first install Java


[root@algo-s ~]# yum install java-1.8.0-openjdk
Loaded plugins: fastestmirror, langpacks
Determining fastest mirrors
epel/x86_64/metalink


Verify Java installation


[root@algo-s ~]# java -version

openjdk version "1.8.0_272"
OpenJDK Runtime Environment (build 1.8.0_272-b10)
OpenJDK 64-Bit Server VM (build 25.272-b10, mixed mode)
[root@algo-s ~]#


Download Jenkins repository


[root@algo-s ~]# wget -O /etc/yum.repos.d/jenkins.repo https://pkg.jenkins.io/redhat-stable/jenkins.repo

--2020-11-15 19:52:08--  https://pkg.jenkins.io/redhat-stable/jenkins.repo
Resolving pkg.jenkins.io (pkg.jenkins.io)... 151.101.158.133, 2a04:4e42:25::645
Connecting to pkg.jenkins.io (pkg.jenkins.io)|151.101.158.133|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 85
Saving to: ‘/etc/yum.repos.d/jenkins.repo’

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

2020-11-15 19:52:08 (7.37 MB/s) - ‘/etc/yum.repos.d/jenkins.repo’ saved [85/85]

Import gpg key


[root@algo-s ~]# rpm --import https://pkg.jenkins.io/redhat-stable/jenkins.io.key
[root@algo-s ~]#


Update yum packages



[root@algo-s ~]# yum update
Loaded plugins: fastestmirror, langpacks


Install Jenkins


[root@algo-s ~]# yum install jenkins


Reload systemd manager configuration


[root@algo-s ~]# systemctl daemon-reload


Start Jenkins server


[root@algo-s ~]# systemctl start jenkins


Check Jenkins server status


[root@algo-s ~]# 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 Sun 2020-11-15 21:42:23 IST; 31s ago
     Docs: man:systemd-sysv-generator(8)
  Process: 14358 ExecStart=/etc/rc.d/init.d/jenkins start (code=exited, status=0/SUCCESS)
   CGroup: /system.slice/jenkins.service


If you are able to see output similar to as shown above, than Jenkins is successfully installed.

Allow tcp connections on port 8080 for Jenkins

[root@algo-s ~]# sudo firewall-cmd --zone=public --permanent --add-port=8080/tcp
success
[root@algo-s ~]# sudo firewall-cmd --reload
success


Now on browser navigate to http://"your-server-IP-or-hostname":8080, you should see Jenkins getting started screen

Retrieve the default generated password from below path and set up Jenkins with Plugins



[root@algo-s ~]# cat /var/lib/jenkins/secrets/initialAdminPassword



Follow US on Twitter: