Jenkins
Jenkins is a popular open-source automation server that helps with Continuous Integration and Continuous Delivery (CI/CD) processes. It allows developers to automate the building, testing, and deployment of software applications.
In this document, you will learn about how to integrate AgileTest with Jenkins.
Firstly, you need to acquire Client id and Client secret from AgileTest. Please refer to this document for more details Access API documentation.
Make sure your account has permission to create TestCase and TestExecution issues; otherwise, the import will fail.
Setup with Jenkins
While this page covers the basics of integrating AgileTest with Jenkins, it will not cover the fundamentals of Docker, which you can refer to in the Docker Getting Started Guide and install Docker on your local machine before proceeding further.
In Jenkins, go to Dashboard → Manage Jenkins → System → Global properties and tick Environment variables. Then, create 2 variables CLIENT_ID and CLIENT_SECRET and fill in your Client id and Client secret respectively.

Global properties
Upload test result
Here is a JUnit report example to experiment with.
If you need more detailed examples, please refer to our public repository on AgileTest GitHub for other sample projects.
Use API
Next, go back to Dashboard and create a new item of scripted pipeline type.

Then link this pipeline to your project repository.
Below is an example of .jenkinsfile. In it, we add another variable named PROJECT_KEY and assign it with Jira project key, for example “ATP”.
pipeline {
agent {
docker {image 'maven:3.9.9-amazoncorretto-17-al2023'}
}
environment{
PROJECT_KEY = 'ATP'
}
stages {
stage('Run test') {
steps {
script{
sh'echo "Testing.."'
sh'mvn test'
token=sh(script: """curl 'https://agiletest.atlas.devsamurai.com/api/apikeys/authenticate' -X POST -H 'Content-Type:application/json' --data '{"clientId":"'"${env.CLIENT_ID}"'","clientSecret":"'"${env.CLIENT_SECRET}"'"}'""", returnStdout:true).trim()
echo "${token}"
sh"""curl "https://api.agiletest.app/ds/test-executions/junit?projectKey=${PROJECT_KEY}" -X POST -H 'Content-Type:application/xml' -H "Authorization:JWT ${token}" --data "@target/surefire-reports/TEST-calculateTest.xml" """
}
}
}
}
}
In this file, we use 2 endpoints
api/v1/apikeys/authenticate
to get temporary token using acquired client_id and client_secret.ds/test-executions/nunit
to submit test report to Agile Test so that the application could create or update Test execution and Test cases accordingly.
To learn more about these endpoints, please refer to this document API documentation.
Use AgileTest CLI
Agile Test also offers you a simpler way to upload your test result via CLI.
You could find the specs of our CLI here: https://agiletestapp.github.io/agiletest-cli/ .
Below is a sample .jenkinsfile
pipeline {
agent none
environment{
PROJECT_KEY = 'ATP'
}
stages {
stage('Run test') {
agent {
docker {
image 'maven:3.9.9-amazoncorretto-17-al2023'
}
}
steps {
script {
sh'echo "Testing.."'
sh'mvn test'
}
stash includes: '**/target/surefire-reports/*.xml', name: 'reports'
}
}
stage('Upload report') {
agent {
docker {
image 'ghcr.io/agiletestapp/agiletest-cli:latest'
args '--entrypoint=""'
}
}
steps {
echo "test"
sh 'ls'
script {
sh'''agiletest --client-id ${CLIENT_ID} --client-secret ${CLIENT_SECRET} \
test-execution import \
--framework-type junit --project-key ${PROJECT_KEY} \
target/surefire-reports/TEST-calculateTest.xml'''
}
}
}
}
}
This file sets up two stages: Run Test and Upload Report. Each stage runs in a separate container using a different image. The Run Test stage uses a Maven image to execute the tests, while the Upload Report stage uses a Docker image designed specifically for the Agile Test CLI to upload the test results.
In Run test stage, we run the automation test scripts and the process yields the reports. Then, in Upload report stage, the report is uploaded to Agile Test by using AgileTest CLI. Below is the command used for the task.
agiletest --client-id ${CLIENT_ID} --client-secret ${CLIENT_SECRET} \
test-execution import \
--framework-type junit --project-key ${PROJECT_KEY} \
target/surefire-reports/TEST-calculateTest.xml
For each test run, a new Test Execution will be created along with linked Test Cases. However, if the Test Cases already exist in your project, Agile Test will only generate a new Test Execution and link the matching Test Cases to it, including the test results.
Should you need any assistance or further AgileTest inquiries, contact here!