Setting up an automation project in Jenkins for Continuous Integration

Jenkins Installation:

Contents

The most popular tool in this genre would be “Jenkins“. It is an open source continuous integration tool that is very popular now a days for continuous deployment.

Well I would be explaining my viewers today how can you use Jenkins to run your tests automatically.

Installation:

I am using an Ubuntu 16.04 machine. So I would be explaining the installation as per Debian standard.

  1. To install Jenkins in Ubuntu please follow the following set of instructions
    wget -q -O - https://pkg.jenkins.io/debian/jenkins-ci.org.key | sudo apt-key add -
    sudo sh -c 'echo deb http://pkg.jenkins.io/debian-stable binary/ > /etc/apt/sources.list.d/jenkins.list'
    sudo apt-get update
    sudo apt-get install jenkins
  2. After installation if you want to upgrade your Jenkins to the latest version you can follow the following set of instruction.
    sudo apt-get update
    sudo apt-get install jenkins

Pre-Requisites:

  1. Java should be installed within the system with its class path set.
  2. Maven should be installed within the system with its class path set. For those who have no idea about maven let me just brief you about maven. It is a build tool that helps running your automation tests independent of any platform.
  3. Jenkins should be installed within the system. If Jenkins is locally installed then it will be running on port 8080.
  4. Eclipse should be up and running.
  5. Github should be installed within your system.

Creating a maven project using eclipse:

To create a maven project using eclipse follow the required steps

Step-1: After opening eclipse goto File > Project > Maven Project. Follow the screenshot

eclipse2

Step-2: Set artifact id for archetype to ‘quickstart‘. Follow the screenshot

eclipse3

Step-3: Add a group id name and a artifact id name. These would basically be your packages under which you will be writing your tests. After this click on finish. Follow the screenshot.

eclipse4

Once your maven project is configured the directory structure would look something like this.

eclipse5

Now once your code is up and running push it to git hub and then we can configure Jenkins to run your automation code from git hub itself.

Setting up Jenkins:

To set up Jenkins please follow the steps.

Step-1: Create a new project by clicking ‘New Item

jenkins1

Step-2: Select the option ‘Maven project‘. Give the name of the project and click on ok.

jenkins2

Step-3: Provide a description of the project if you want to. Next select Git as the option for Source Code Management.

jenkins3

Also enter the ‘repository url‘ and the ‘branch‘ on which the updated code is present

jenkins4

Step-4: Give the path of your root POM within the project and set the goal to clean install. This would basically make a clean build each time the script is executed. For first time you can set ‘clean install‘ for ‘Goals and Options‘. The next time you run the script you can change it to ‘clean test‘.

jenkins5

Step-5: Next if you click on the option ‘Build Now‘ on your extreme left the build would start and it would look something like this.

jenkin6

Now to remove complete dependency for triggering the Jenkins build you can set up a scheduler for Jenkins that would schedule the job to be build at a continuous period of time. Follow the screenshot to understand.

scheduler

You can also trigger the Jenkins build when a code is pushed onto git hub by checking the option “Build when a changed is pushed to GitHub“. Follow the screenshot to understand

scheduler2




Soumyajit Basu

Soumyajit is 5+ years experienced Software professional with his prime focus on automation technologies based on quality development and takes interest in the CI/CD processes. He provides help in developing the QA process in an organization with his skills in automation for the web platform. His focus is on improving the delivery process for an ongoing project and connects the dot to help out with a successful deployment. He has experience in working on analytics, e-commerce, and the ad-tech domain.

Besides being a professional he takes an immense interest in learning new skills and technologies. He is a research guide author/writer at Dzone and Web Code Geeks. He also maintains a blog platform of his own where he likes to keep up his technology junks.

Leave a Reply

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