Getting Started With Jenkins(Part-1)

Updated: Sep 1, 2020

What Is The Concept of CI/CD ?

This is probably the most common term in the devops world, CI/CD stands for Continuous Integration and Continuous Delivery.

Let's discuss about how development used to happen before CI/CD came in to picture. Earlier a base working code was developed with some of the functionalities that were good to go with.

Different teams (back-end, front-end etc.) used to download the code from the repository and started working with their own portion.Once they all are done with their own parts , integration of code will happen.

The integration area is where the real problem lies because of the teams didn't communicate with each other so there was lack of transparency.

Only the development team had an idea of what logic is being used and what methods need to be exposed but no one tested these before.

So problems used to occur at the time of integration and it took longer to get the project completed.

The relief to the above situation was CI/CD.

Here developers commit their code in to the repository very often. Each Commit has some improvements or additional code. Each commit triggers an automated workflow on a CI server(Jenkins) that can notify developers of any failure or success of the integration. This way, the code is deployed in small increments, tested and ultimately put to production which was far more productive.

Continuous Delivery is a discipline where software is developed in such a manner that allows to deploy code in production anytime. Please note, this doesn't mean that code has to be deployed but it makes it feasible for the deployment to happen in production if required.

This gives us a possibility of continuously getting feedback regarding code deployment, code quality and a way to trigger deployment in production if everything is fine in dev environment.

Jenkins Installation

Jenkins is a free and open source automation server. It helps automate the parts of software development related to building, testing, deploying, facilitating continuous integration and continuous delivery.

To install jenkins we will use 2 CentOS 7 machines(64 bits) node1 # Jenkins Master node2 # Jenkins Slave

  • On Jenkins master (node1), login with root and follow the below steps

[root@node1 ~]# pwd
[root@node1 ~]# wget -O /etc/yum.repos.d/jenkins.repo
--2020-06-08 11:36:21--
Resolving (, 2a04:4e42:24::645
Connecting to (||: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-06-08 11:36:21 (5.75 MB/s) -/etc/yum.repos.d/jenkins.repo’ saved [85/85]

[root@node1 ~]# rpm --import
[root@node1 ~]# yum install jenkins -y
  • Note that jenkins user will be created with a no login shell.

  • Execute below command to change the shell of jenkins user to /bin/bash so that jenkins is able to take the console.

[root@node1 ~]# chsh -s /bin/bash jenkins
Changing shell for jenkins.
chsh: Shell changed.

  • Give sudo access to jenkins user. For this append the below line to /etc/sudoers file.

 jenkins ALL=(ALL)       NOPASSWD: ALL
  • Reset password for jenkins user

[root@node1 ~]# passwd jenkins
Changing password for user jenkins.
New password:
BAD PASSWORD: The password is a palindrome
Retype new password:
passwd: all authentication tokens updated successfully.
  • Install java

yum install java-1.8.0-openjdk.x86_64 -y 
  • Now login with jenkins user and start jenkins service.

[root@node1 ~]# su - jenkins
Last login: Mon Jun  8 11:49:43 IST 2020 on pts/1
-bash-4.2$ sudo systemctl start jenkins && sudo systemctl enable jenkins && sudo systemctl status jenkins
jenkins.service is not a native service, redirecting to /sbin/chkconfig.
Executing /sbin/chkconfig jenkins on
● jenkins.service - LSB: Jenkins Automation Server
   Loaded: loaded (/etc/rc.d/init.d/j