Continuous Integration Testing with Jenkins
Limited Time Offer!
For Less Than the Cost of a Starbucks Coffee, Access All DevOpsSchool Videos on YouTube Unlimitedly.
Master DevOps, SRE, DevSecOps Skills!
In software development and testing fields, Continuous Integration (CI) is an exercise of combining all development work to a shared main server several times a day. The goal of CI is to reduce time and effort required for a product launch. The process of continuous integration is achieved with the help of version control, strategies & contracts and special tools.
One of the famous tools used for CI testing is Jenkins.
“Jenkins is an open source automation tool, which can be used to program all categories of tasks such as building, testing, and deploying software. Jenkins can be installed through native system packages, Docker, or even run standalone by any machine with the Java Run-time Environment installed.”
It helps to automate the non-human part of the software development life-cycle.
Jenkin pipeline is a package of plugins used for implementing the CI process in the delivery pipeline. Extensive set of tools are available with pipeline for modelling simple to complex delivery pipelines. It is a server based tool, which runs on Java servlet such as Apache Tomcat. It supports source control management such as AccuRev, CVS, Git, Mercurial, Subversion, RTC, Perforce and Clearcase.
There are a lot of plugins released for Jenkins to extend its use to projects, which are written in various languages besides Java.
Below is the flow diagram to explain how continuous integration testing can be done with Jenkins.
Now let’s take a look how to configure and manage Jenkins
Step 1
Download Jenkins from the website https://jenkins.io
Step 2
Login to the Jenkins
E-Mail Configuration:
Step 3
Click on ‘Manage Jenkins’ link
Step 4
Click on ‘Configure System’ link
Step 5
Configure the fields given as screenshot
Step 6
Enter ‘System Admin’ Email Id
Step 7
Enter the following fields on the ‘Extended Email Notification section –Ref’ screenshot
SMTP Server: smtp.gmail.com
Default user E-mail suffix: @gmail.com
Default Recipients: your123@gmail.com
Reply To List: noreply@gmail.com
Default Content Type: $PROJECT_NAME – Build # $BUILD_NUMBER – $BUILD_STATUS!
Step 8
Select the checkbox option given on the screen shot to Trigger the Email
Step 9
Enter the fields on the ‘E-mail Notification’ section as given on the screenshot
Select ‘Test Configuration’ checkbox then click on ‘Test Configuration’ button. You will get success message like – “Email was successfully sent” [if you get this message means you have configured successfully] then Click on ‘Save’ button.
Steps to create a new Project in Jenkins and Project Configuration
Step 1
Go to Jenkins -> New Item
Step 2
Enter project name and select ‘Freestyle Project’ then click on ‘OK’ button
Step 3
Click on tab ‘General’
Step 4
Set the time on ‘Build Trigger’ Section
Example Time:
# every fifteen minutes (perhaps at :07, :22, :37, :52)
H/15 * * * *
# every ten minutes in the first half of every hour (three times, perhaps at :04, :14, :24)
H(0-29)/10 * * * *
# once every two hours at 45 minutes past the hour starting at 9:45 AM and finishing at 3:45 PM every weekday.
45 9-16/2 * * 1-5
# once in every two hours slot between 9 AM and 5 PM every weekday (perhaps at 10:38 AM, 12:38 PM, 2:38 PM, 4:38 PM)
H H(9-16)/2 * * 1-5
# once a day on the 1st and 15th of every month except December
H H 1,15 1-11 *
Step 5
Enter the name of your .bat file on the ‘Build’ section
Step 6
Fill the field on the ‘Post-build Actions’ section given as screenshot
Step 7
Click on ‘Save’ button
Step 8
Click on your Project then click -> Build Now; you will get the ‘Build Executor Status’ as following screenshot.
Step 9
Once if the build get completed click on the build number then view the console output
Step 10
The console output will be following screenshot