Check our Courses - New Batch for: API - Demo Session at 13th Feb Batch starts from 20th Feb | DevOps - Demo Session at 13th Feb Batch starts from 20th Feb | Java & Selenium - Batch starts from 12th Dec (Weekend Batch) | Python & Selenium - Batch starts from 9th Jan (Weekend Batch)

Jenkins Setup on CentOS

1. First do sudo yum install wget

Wget command is a Linux command line utility that helps us to download the files from the web. We can download the files from web servers using HTTP, HTTPS and FTP protocols. We can use wget in scripts and cronjobs. Wget is a non-interactive program so that it will run in the background.

2. Get the latest Jenkins repo in local server by using the following command

sudo wget -O /etc/yum.repos.d/jenkins.repo
(it is -O is alphat capital O)
You should see the following on your linux terminal.

[centos@ip-172-31-28-251 ~]$ sudo wget -o /etc/yum.repos.d/jenkins.repo http://p kg.jenkins-ci .org/redhat/jenkins.repo

–2018-10-15 07:15:44– Resolving ( …

Connecting to ( || :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-10-15 07:15:44 (11.0 MB/s) – ‘/etc/yum.repos.d/jenkins.repo’ saved [71/71]

3. Now import the Jenkins repo associated key with that repository so that we ensure it is secure
sudo rpm –import
If you get back to command prompt without any error then key download was successful

4. Do sudo yum update to ensure our package caches are uptodate and includes the latest repository information. Now we are ready to install Jenkins from our repository just downloaded. Part of the output post update would look like as given below:

Transaction Summary
Upgrade 1 Package

Total download size: 25 k
Is this ok [y/d/n]: y
Downloading Packages:
Delta RPMs disabled because /usr/bin/applydeltarpm not installed.
centos-release-7-5.1804.5.e17.centos.x86_64.rpm                    |         25 KB                 00:00
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction test
Transaction test succeeded
Running transaction
Updating : centos-release- 7-5.1804.5.el7.centos.x86_64                                                             1/2
Cleanup :  centos-release- 7-5.1804.4.el7.centos.x86_64                                                              2/2
Verifying : centos-release- 7-5.1804.5.el7.centos.x86_64                                                              1/2
Verifying : centos-release- 7-5.1804.4.el7.centos.x86_64                                                              2/2

centos-release.x86_64 0:7 – 5.1804.5.el7.centos


5. Now execute sudo yum install Jenkins this will install Jenkins along with any dependencies
You should get the following message:

jenkins             noarch              2.147-1.1                   jenkins               72 M

Transaction Summary
Install 1 Package

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

jenkins.noarch 0:2.147-1.1


What this package installation does”

• Jenkins will be launched as a daemon on startup. See /etc/init.d/jenkins for more details.
• The ‘jenkins’ user is created to run this service. If you change this to a different user via the config file, you must change the owner of /var/log/jenkins, /var/lib/jenkins, and /var/cache/jenkins.
• Log file will be placed in /var/log/jenkins/jenkins.log. Check this file if you are troubleshooting Jenkins.
• /etc/sysconfig/jenkins will capture configuration parameters for the launch.
• By default, Jenkins listen on port 8080. Access this port with your browser to start configuration. Note that the built-in firewall may have to be opened to access this port from other computers. (See for instructions how to disable the firewall permanently)
• A Jenkins RPM repository is added in /etc/yum.repos.d/jenkins.repo

6. Jenkins package is going to rely on Java. So now we need to install Java(Approx 118 MB download).
sudo yum install java-1.8.0-openjdk

7. Verify that Jenkins installed successfully.
We need to connect TCP port 8080 so check if there is no firewall by systemctl status firewalld and systemctl status iptables

If you have firewall then we need to add this port

8. Now start the Jenkins by
systemctl start jenkins
systemctl status jenkins -l – (alphabet l) (to check it is running)
(Note: Systemctl is a systemd utility to control system and service manager. Systemd is a collection of software that provides building blocks for Linux OS. Systemd functions as central management and configuration platform for UNIX.)
9. Got AWS console. Select the security group created during EC2 instance creation and add the inbound rules for 80 and 8080

10. Go to your browser and type “PublicIPAddress:8080”
11. You will be asked to put admin password. Go to your Linux server from git bash and type following command:
sudo cat /var/lib/jenkins/secrets/initialAdminPassword
and you will see your password like this “1662fdb9075f4646bad79ac323a2bab4”. Copy this by CTRL+C and paste it in the password field in your browser.

12. Then it will ask you two options

Select Install Suggested plugins for now. We will install other plug-ins as and when required.

13. After installation for plugin the following screen will appear, please make sure you remember your id and password as it will be required every time you want work with Jenkins.

14. You will get the following screen. Verify the IP address is matching with your public IP address, same will be in your url field. Click on Save and Finish.

Congratulations if you have seen the following screen, otherwise, google it for answers

Click on “Start using Jenkins” and you should see the following screen.

December 10, 2018