Skip to content
5th Anniversary
Celebrating five years of engineering-led delivery and client success.Our story
Celebrating five years of engineering-led delivery and client success.Our story
CI/CD AutomationJenkins Pipeline

Setup Jenkins Job to Execute Automation Tests

This blog will help you set up automation test jobs on Jenkins, providing a step-by-step guide or tutorial to streamline your development process with ease.

Jenkins

Server or VM

Jenkins "Master" node

Server or VM

Slave Agent "Slave" node

Setup Jenkins Job to Execute Automation Tests

Prerequisites

  1. Jenkins Installed & operational.
  2. Automation Test Code for sample test.
  3. GitHub repository details for automation test code.

Steps To Configure Jenkins Job:

1

Open your Jenkins dashboard in a web browser and log in.

2

Create a New Item

Click on "New Item" on the Jenkins dashboard. Enter a name for your job, like "LaunchWebsiteJob". Select "Freestyle project" and click "OK".

Enter an item name

LaunchWebsiteJob

Freestyle project

Classic, general-purpose job type that checks out from up to one SCM, executes build steps serially, followed by post-build steps like archiving artifacts and sending email notifications.

Pipeline

Orchestrates long-running activities that can span multiple build agents. Suitable for building pipelines and/or organizing complex activities that do not easily fit in free-style job type.

Multi-configuration project

Suitable for projects that need a large number of different configurations, such as testing on multiple environments, platform-specific builds, etc.

OK
3

Configure General Settings

Scroll down to the "General" section. Optionally, you can provide a description for your job. You can also restrict where this project can be run, but leaving it blank will allow it to run on any available agent.

Configure

General
Source Code Management
Build Triggers
Build Environment
Build Steps
Post-build Actions

Description

This Jenkins Job will navigate to the website
Discard old builds
GitHub project
This project is parameterised
Throttle builds
Execute concurrent builds if necessary
Advanced
SaveApply
4

Configure Source Code Management (SCM)

If your website's source code is stored in a version control system like Git, you can configure the SCM here. Select your SCM option (e.g., Git). Enter the repository URL. You can also specify the branch to build if needed.

Configure

General
Source Code Management
Build Triggers
Build Environment
Build Steps
Post-build Actions

Source Code Management

None
Git

Build Triggers

Trigger builds remotely (e.g., from scripts)
Build after other projects are built
Build periodically
GitHub hook trigger for GITScm polling
Poll SCM
SaveApply
5

Configure Build Triggers

Scroll down to the "Build Triggers" section. Select how you want to trigger the build. For example, you can choose to build periodically or trigger the build remotely.

Configure

General
Source Code Management
Build Triggers
Build Environment
Build Steps
Post-build Actions

Build Triggers

Trigger builds remotely (e.g., from scripts)
Build after other projects are built
Build periodically
GitHub hook trigger for GITScm polling
Poll SCM
SaveApply
6

Configure Build Steps

Scroll down to the "Build" section. Click on "Add build step" and select the appropriate build step for your website. For example: To run a pytest command, we can use below command

pytest -m=sanity --browser=chrome --url=https://www.smartspendops.com/ --headless=false --allureReport=true

Enter the necessary build commands or scripts.

Configure

General
Source Code Management
Build Triggers
Build Environment
Build Steps
Post-build Actions

Build Steps

Add build step
Execute Windows batch command
Execute shell
Invoke Ant
Invoke Gradle script
Invoke top-level Maven targets
Run with timeout
Set build status to "pending" on GitHub commit

Build Steps

Execute Windows batch command

Command

See the list of available environment variables

pytest -m=sanity --browser=chrome --url=https://www.smartspendops.com/ --headless=false --allureReport=true
Advanced
SaveApply
7

Configure Post-Build Actions

Scroll down to the "Post-build Actions" section. Procedure for adding Allure reports to the Jenkins Job.

Go to Jenkins dashboard. Select manage Jenkins.

Jenkins

+ New Item

People

Build History

Manage Jenkins

My Views

SWName
LaunchWebsiteJob

Click on manage plugin. Search for the allure report in the available plugin.

Plugins

allure

Allure 2.31.1

Build Reports

This plugin integrates Allure reporting tool into Jenkins.

Click on install without restart. Click on the global tools in Manage Jenkins > Tools. Select Allure Command line installations.

Allure Commandline installations

Add Allure Commandline
SaveApply

Give 'ALLURE_HOME' in the name. And the path of the allure folder in the installation directory and click on Save button.

Allure Commandline

Name

ALLURE_HOME

Installation directory

 
Install automatically
Add Allure Commandline
SaveApply

In job configuration select post-build action. Select allure report. Give the path of allure report in 'Path'.

Post-build Actions

Allure Report

Disabled

Results:

Paths to Allure results directories relative from workspace. E.g. target/allure-results.

Path

allure-results
Add
SaveApply
8

Save your Jenkins Job Configuration

Click on "Save" to save your Jenkins job configuration.

Configure

General
Source Code Management
Build Triggers
Build Environment
Build Steps
Post-build Actions
start chrome https://www.smartspendops.com
Advanced
Add build step

Post-build Actions

Add post-build action
SaveApply
9

Run the Jenkins Job

Click on "Build Now" to run your Jenkins job and launch your website.

Status

Changes

Workspace

Build Now

Configure

Delete Project

Rename

LaunchWebsiteJob

This Jenkins Job will navigate to the website

Permalinks

Build History

No builds

10

Monitor the Jenkins Job

Once the job is running, you can monitor its progress on the Jenkins dashboard.

Status

Changes

Console Output

View as plain text

Edit Build Information

Delete build #1

Console Output

Started by user Krishna Pukale
Running as SYSTEM
Building in workspace C:\Users\User\.jenkins\workspace\LaunchWebsiteJob
[LaunchWebsiteJob] $ cmd /c call C:\Users\User\AppData\Local\Temp\jenkins7999765259831331340.bat
C:\Users\User\.jenkins\workspace\LaunchWebsiteJob>start chrome https://www.smartspendops.com
C:\Users\User\.jenkins\workspace\LaunchWebsiteJob>exit 0
Finished: SUCCESS

This is how you can configure a simple Jenkins Job to execute automation tests. Please feel free to reach out to me on krishna.pukale@refactorq.com if need any assistance in setting up a Jenkins Job for Automation Tests.

Related Engineering Practice

Cloud, DevOps & SRE Engineering

Standardise cloud environments, construct automated delivery pipelines, and establish production observability.

Explore Cloud, DevOps & SRE Engineering Services
Start a conversation

Have a production bottleneck or modernization initiative?

Tell us where your software architecture or cloud environment is experiencing friction. A senior engineer will review your challenge and outline an actionable technical roadmap.

Book a call (opens Microsoft Bookings in a new tab)30 minutes with a senior engineer

A senior engineer reads every enquiry and replies within one business day