Integrating Jenkins with Selenium.

Reading Time: 4 minutes

Hi folks,

In this blog, we will try to integrate Selenium with Jenkins. We will not try this on an ubuntu machine using a bash file instead of a standard batch(windows compatible) file so that we need to run it in headless mode.

So, let’s get going.

What is Jenkins?

  • Jenkins is an open-source tool written in Java. 
  • It provides continuous delivery and continuous Integration for software development.
  • In short, it automates our manual task of the code deployment process.
  • For example, when you want to base the execution on time you can run a job every 20 minutes or if you want to base it on an event you can do so after a new commit in a Git repository.

Why are we doing this?

The main here is to do CI/CD integration. With this achieved, we can have an automated way of running our regression test. Whenever we have any changes to our VCS repo and we can have our test run in parallel along with the project build. So that we can identify any bugs or defects even when there is a small change of functionality or code.

Jenkins usage and integration with selenium.

Setting up Jenkins

First of all, we need to download Jenkins to our local system. It is recommended that we should download the generic java package (.war) file as it can be executed on almost every OS. We can download it from here, .

After downloading it, open the terminal and open the directory where this .war file is present. Afterward, execute the command

java -jar jenkins.war

Now while it is running, open this address in our web browser http://localhost:8080. Moving forward, something like this will appear on our screen.

We can find the password in our terminal and on the location specified in the image above. Now, we have to install the plugins, it is always safe to install the suggested one.

We can do so by clicking on it, as specified in the image below.

It will take some time to install these plugins, so please be patient. After the plugin installation, we will encounter something like the image given below

We have used sbt as a build tool for this, so we need to configure sbt as well.

How to configure sbt?

Firstly, we need to install the sbt plugin. We can do so via the “Manage Jenkins” and then going into the “Manage Plugins option”. From here can install the sbt plugin.

Now all we have to do is edit the Global Tool configuration, we can do so by clicking on the Manage Jenkins > System Configurations > Global Tool Configuration. Click on Add sbt and we will be needed to name the sbt version and specify the path to the sbt launch jar as well and click on save.

And voila, sbt has been configured with Jenkins.

Configure Jenkins and Running our Selenium Project.

To do so, we would have to create a new job. Go back to the main dashboard click on “Create a new Job“. In this blog, we will call out the mandatory fields that need to be filled while creating a job, the rest of the things are optional.

Firstly, we have to specify the VCS that we are using, for example, here we are using GitHub. Select Git in the Source Code Management section and fill out the repository link and branch(if any).

Ignore the Build Environment part and move to the “Build” section. Click on “Add build step” and select “Build using sbt”.

Then, specify the sbt launcher and we may provide the command for running the script in “Actions”.

Creating a bash file and using it in Jenkins

Firstly, go to your project root directory and create a library(lib) folder and then add all the jars of the project into it.

Create a file with name run.bash in the project root directory.

$ touch run.bash

Open the file and copy-paste the below commands into it , and then close it by saving it.

Java \u2013cp bin;lib/* org.testng.TestNG testng.xml

This will convert that file into a exucteable bash script.

Now, all we have to do is to select “Add build step” again and a dropdown menu will appear. Select “Execute shell” and something like this will appear on your screen.

At last, we just need to specify the command to run the bash script.


That’s it, we just need to click on Save and then Apply and out Selenium project is now integrrated with Jenkins.

Just go the job and click on build now. Your, selenium script will smoothly without the headless mode.

Thanks! I hope you may found this useful.



Written by 

Sparsh is a QA Consultant having experience of more than 2 years. He is familiar with the core concepts of manual and automation, Karate, Cypress, Gatling, Rest Assured and Selenium are the tools that Sparsh is familiar with. He is always eager to learn new and advanced concepts in order to upskill himself.