Jenkins – A Step towards Continuous Integration

Jenkins – A Step towards Continuous Integration

What is Continuous Integration

If you are living in a world where developer codes and assign a ticket QE to test and give go ahead.  The QE deploys the code manually and then start the analysis finds a bug and assigns it to developer and chain goes on until the bug is fixed. If this is your scenario then CI is for you.

Benefits of Continuous Integration

  • The time consumed in manual efforts of deployment vanishes
  • Minimised communication gaps
  • Detect the bug faster
  • No more frustrated QE doing the sanity manually
  • Faster feature release

How to opt for Continuous Integration

Enough of the benefits and theory but so how do you actually implement CI in my environment. To opt for CI we need to make sure of few things first which will help to set up the platform.

  • A shared repository like git
  • A CI server like Jenkins
  • A tool to detect the changes in the repository like webhook
  • An automation framework (optional initially but helps to attain the true CI)

Let’s get started

Step 1 : Create a repository

Sign for GitHub and create your first repository, don’t worry public won’t cost you even a penny. Once the repository is created, initialise it with a readme file.

Create a webhook so that Jenkins can receive information about the repository changes

Go to repository setting and look for “Integrations & services

Look for services option and  opt for “Jenkins (GitHub plugin)”

Provide your Jenkins server’s domain/IP and click “Add service”

 

 

Voila, you are one step closer to your first CI/CD!!

 

Step 2 : Install Jenkins

We are using ubuntu 16.04 to install our Jenkins server.

  • Install Java
apt-get update
apt-get install openjdk-8-jdk -y
  • Add Jenkins package repository’s key
wget -q -O - https://pkg.jenkins.io/debian-stable/jenkins.io.key | sudo apt-key add -
  • Add Jenkins package repository to the system
sudo echo "deb https://pkg.jenkins.io/debian-stable binary/" >> /etc/apt/sources.list.d/jenkins.list
  • Update the local package repository cache
apt-get update
  • Finally, install Jenkins
apt-get install jenkins -y
  • Complete Jenkins setup by opening your Jenkins server web UI on browser http://<your jenkins server ip/domain>:8080

You will be prompted to provide an intial password generated by Jenkins itself, just copy paste the password from below file

cat /var/lib/jenkins/secrets/initialAdminPassword

 

 

 

 

 

 

Step 3: Add Jenkins ssh keys to your GitHub profile

Login to your Jenkins machine and generate your ssh-keys using the below command and follow the instructions

ssh-keygen

copy your public key to GitHub profile. It will allow Jenkins to pull code using your keys.

 

Step 4 . Create Jenkins job.

Name the job name

 

Under Source code management provide your repo url.

 

Voila, you have just set up your first CI/CD with Jenkins!!! 

2 Replies to “Jenkins – A Step towards Continuous Integration”

Leave a Reply

Your email address will not be published. Required fields are marked *