Jenkins Configuration in Git with Selenium

Updated 17 August 2021

Facebook Linkedin

Welcome to jenkins Documentation for people for those people who wanting to use jenkins functionality and plugin  features, and if you want to extend the functionality of jenkins , and interested in developing of your own plugins please go through article https://jenkins.io/doc/developer/. 

What is Jenkins?

Jenkins is an open source tool in which codes are written in form of java. It provides a continous integration service in java, now you are thinking about what is continuos integration and why jenkins provide it.

So Continous integration (CI) is the process of automating a build and testing a code every time, when a team member commit changes in build.

Jenkins is an open source automation server which is used for automating all short of tasks related to development of build, Testing of build , and deploying a software. It support many plugins such as git, MVN, Build pipeline through which you can integrate with Jenkins. The basic functionality of Jenkins is that we can execute our old codes on the basis of time and events, this is done by Build Triggers in Jenkins. In Build triggers we set an interval of time and we create an events thats after each and every new commit, Jenkins started Build our code.

In this Article we cover below points

  • Jenkins Installation.
  • Creating a job file in Jenkins.
  • Jenkins advantages and integration with git.
  • Add selenium script in git and Configure git plugin in Jenkins.
  • running selenium script from command line.

Jenkins Installation

Follow below points Step-by – Step procedures for integration of Jenkins with Selenium

1. Download Jenkins from official website https://jenkins.io/  

2. Download the latest .War file , and Jenkins can be started from command promt or can be in a web application server.

Refer below Steps for execution through command line :

1) Open the command prompt and type java –jar and enter path of .war file.

2) Press enter and  then  your Jenkins.war file started  run and you will see status information in Console.

It will show – Jenkins is fully up and running.

3) Now Jenkins is get Ready to Use , by default it use port 8080

Type http://localhost://8080 and press enter, Dashboard will get open.

Please refer original Document for Jenkins Installation .

 Job profile in Jenkins

It will load Jenkins Dashboard, here i created some job profile.Jenkins advantages

  • Jenkins is an open source tool with much support from its community.
  • Installation is easier.
  • It has more than 1000 plug-in to make the work easier.
  • It is easy to create new Jenkins plugin if one is not available.
  • It is a tool which is written in Java. Hence it can be portable to almost all major platforms.

Jenkins Integration with Git

As in this article we discuss about git integration in Jenkins by running our automating test code of user login panel in akeneo module.

Git is most widely used  modern version today, which allows multiple person to work to safely work on same project without hamper other team members. In a git server you and your team will add test script which are developed by locally and push your changes in git.

We can make Jenkins to pull the project automated code from a git server. by selecting option in source code management and specify the path/url which can define the automated code of project.

In Below example we configure testng.xml file, and our selenium scripts are added in testng.xml. we can add those class name which we want to execute.

Add Selenium Script in git

Create a selenium script and a testng.xml in Eclipse and push your Script in Git , below i mention for akeneo user login :

Refer TestNG code

Configure git plugin Jenkins

Step1:– Manage Jenkins-> Manage Plugins -> go to list to plugins available with ‘Git plugin’. Find more details about Git Plug-in.

Step 2:- Check the Git Plug-in and click on the button ‘Install without restart’.

Step 3:- After the installations are done , Please restart Jenkins by using the command in the browser. http://localhost:8080/jenkins/restart

Once Jenkins is restarted, Git option should be available under source code management in Configure of Build.

Step 4:-

From Manage Jenkins > Configure System, please provide the right Path to Git executable.

Step 5:

# If you want to run job for every fifteen minutes, we should specify cron syntax as below :
H/5 * * * *

#If you want to trigger for, every 2 hours
H */2 * * * to distribute load evenly throughout the hour

In addition to the above, Jenkins also support convenient aliases as @yearly, @annually, @monthly, @weekly, @daily, @midnight, and @hourly.

Step 6:- In Build Settings, to send an email notifications, you can check ‘Email Notification’ and add Recipients address separated by comma.

Step 7:– Run Selenium Script in Build section by Below command:

Step 8:- Click on Apply and Save.

Now as per configuration above, the build will trigger for every 5 minutes.

Once when the build is triggered, you can check for the console output, which will show you something like below image :-

. . .

Leave a Comment

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

Be the first to comment.