In this article you will learn how to integrate the Applitools test results Dashboard into your Jenkins Build Report. This integration requires using Batches, a feature that allows you to group several tests together.
Behind the scenes, Applitools Jenkins plugin generates a unique batch-id passed via env. variable to the tests and tracks the batch in job's build report. Every Jenkins job will show you the results of a specific batch of tests in Applitools.
Installing the Applitools eyes Jenkins plugin:
Go to the project in Jenkins that you want to integrate. Then click on "Manage Jenkins" (1) and then go to "Manage Plugins" (2).
Then go to the "Available" plugin list (3) and search for "Applitools" (4). After the search, install the "Applitools Eyes Plugin" (5) without restart (6).
Behind the scenes, Applitools Jenkins plugin generates a unique batch-id passed via env. variable to the tests and tracks the batch in job's build report. Every Jenkins job will show you the results of a specific batch of tests in Applitools.
Installing the Applitools eyes Jenkins plugin:
Go to the project in Jenkins that you want to integrate. Then click on "Manage Jenkins" (1) and then go to "Manage Plugins" (2).
Then go to the "Available" plugin list (3) and search for "Applitools" (4). After the search, install the "Applitools Eyes Plugin" (5) without restart (6).
Project configuration - Free style project
Go back to your Jenkins project, and click on "Configure" (7).
Now you can find under "Build Environment" an option titled "Applitools support" (8). If you're using the public cloud, leave the URL as it is, but if you're using a private cloud, change the URL according to your server's address and press "Save".
Now you can find under "Build Environment" an option titled "Applitools support" (8). If you're using the public cloud, leave the URL as it is, but if you're using a private cloud, change the URL according to your server's address and press "Save".
Project configuration - Pipeline project
To use the Applitools plugin in a pipeline project, you need to add the Applitools() directive and put your run code in a block. Following is a script example:
node { stage('Applitools build') { Applitools() { sh 'mvn clean test' }
}
}
If you are using a dedicated Applitools Eyes server, you should update the Applitools URL accordingly inside the Applitools directive. For example:
node { stage('Applitools build') { Applitools('https://myprivateserver.com') { sh 'mvn clean test' }
}
}
Linking the Applitools batch ID with the relevant Jenkins Job:
The batch-ID parameter is passed through an environment variable called APPLITOOLS_BATCH_ID to the executed tests, and the build name is passed through an environment variable called APPLITOOLS_BATCH_NAME.
To set the batch name and the batch-ID in your test code, use the following syntax before starting your tests:
The batch-ID parameter is passed through an environment variable called APPLITOOLS_BATCH_ID to the executed tests, and the build name is passed through an environment variable called APPLITOOLS_BATCH_NAME.
To set the batch name and the batch-ID in your test code, use the following syntax before starting your tests:
JAVA:
//Set only once per Jenkins job
BatchInfo mybatch = new BatchInfo(System.getenv("APPLITOOLS_BATCH_NAME"));
mybatch.setId(System.getenv("APPLITOOLS_BATCH_ID"));
//End of - Set only once per Jenkins job
eyes.setBatch(mybatch);
Ruby:
#Set only once per Jenkins job
batchInfo = Applitools::BatchInfo.new( ENV["APPLITOOLS_BATCH_NAME"])
batchInfo.id = ENV["APPLITOOLS_BATCH_ID"]
#End of - Set only once per Jenkins job
eyes.batch = batchInfo
Python:
import os
from applitools.eyes import BatchInfo
#Set only once per Jenkins job
batchInfo = BatchInfo(os.environ['APPLITOOLS_BATCH_NAME’])
batchInfo.id_ = os.environ['APPLITOOLS_BATCH_ID’]
#End of - Set only once per Jenkins job
eyes.batch = batchInfo
.NET:
///Set only once per Jenkins job
batchInfo = new BatchInfo(Environment.GetEnvironmentVariable("APPLITOOLS_BATCH_NAME") );
batchInfo.Id = Environment.GetEnvironmentVariable("APPLITOOLS_BATCH_ID");
///End of - Set only once per Jenkins job
eyes.Batch = batchInfo;
JavaScript:
eyes.setBatch(process.env.APPLITOOLS_BATCH_NAME, process.env.APPLITOOLS_BATCH_ID);
This is it - you're done!
The next time you build a project with Jenkins, you will be able to get the Applitools test results integrated into your Jenkins Build Report, as can be seen below:
The next time you build a project with Jenkins, you will be able to get the Applitools test results integrated into your Jenkins Build Report, as can be seen below:
(If you are working with a dedicated cloud, but you receive an Access Denied message when reviewing your test results, try to log out from your Applitools account and then log back in, and then re-enter Jenkins.
If this doesn't work, clear your cookies from the browser and try logging in again.)
If this doesn't work, clear your cookies from the browser and try logging in again.)
For a video tutorial about the Jenkins integration, please visit our blog post, and for further details please visit our official Jenkins plugin documentation.