Hi all, in this article I will explain how to integrate Jenkins with your Selenium JAVA Maven projects. The tool-set is listed below.

First, you need to install Jenkins.

Then, install below plugins if they are not installed. GitLab and Git plugins are optional if you use another Version Control System (VCS) you can install that VCS’s plugins.

Then, go to Global Tool Configuration page on Jenkins and configure the JDK and do maven settings as shown below.

Configure the git if you use git as a VCS.

Configure SonarQube settings if you use SonarQube as a static code analysis tool.

and finally configure Maven settings.

Then, go to Jenkins -> Configurations page and do below settings.

Maven Settings

SonarQube Server Settings (Optional)

GitLab Web Hook Settings (Optional)

GitLab Settings (Optional – This part depends on your VCS tool)

Jenkins and Slack Webhook Settings (Optional)

SonarQube Quality Gate Settings (Optional)

Gitlab, Mail and Slack Notificaiton Settings (Optional)

Global Slack Notifier Settings (Optional – We use Slack and we will follow all activities on CI channel.)

GitLab Merge Request Builder Settings (Optional)

Then create a job, open the job’s page and click “Configure“.

Do the below settings.

Below, we give name to the project and we will keep only last 3 builds on the Jenkins server.

Set Gitlab Connection Settings.

If your test suite gets some parameters, you can set them when you run your Jenkins jobs by doing below settings.

In the code, we use these parameters as follows:

Then, we need to get the latest codes from VCS (for us it is GitLab) with below settings and operations:

If you want you can set a trigger to run Jenkins job or you can trigger the Jenkins job manually.

If you want to check your quality by SonarQube, you should do below setting. At Build part, you need to use pom.xml and maven command for clean your build folder and test it with static code analysis. If you do not use SonarQube you should remove “sonar:sonar” part of the maven command.

You can configure your mail notifications and also at Post-build Actions, you need to publish test results. In below settings I used our extentreports’s report HTML file. Also, I configured TestNG test results to publish them.

In order to publish build status on GitLab, you can use below post build action. But it is an optional setting.

Then, when you run your job, you will have results as shown below. The below is my Jenkins Job’s dashboard.

Selenium Webdriver Tutorial Series