Bitbucket
Bitbucket is one of the widely known CI/CD tool. In this document, we will show you how to integrate AgileTest with Bitbucket via REST API.
However, in order to utilize AgileTest API, Client id and Client secret are needed. Please refer to this instruction to get them first Access API documentation.
Make sure your account has permission to create TestCase and TestExecution issues; otherwise, the import will fail.
Setup your Bitbucket repository
In your Bitbucket repository, go to Repository settings → Repository variables and create respective repository variables for acquired client id and client secret.
In this example, we will create 3 repository variables CLIENT_ID, CLIENT_SECRET, and PROJECT_KEY.

Repository variables
Upload test result
Here is a sample NUnit report to play around with.
If you need more detailed examples, please refer to our public repository on AgileTest GitHub for additional sample projects.
Use API
Below is a sample bitbucket-pipelines.yml file.
image: mcr.microsoft.com/dotnet/sdk
options:
docker: true
definitions:
steps:
- step: &linting
name: Linting
caches:
- dotnetcore
script:
- echo "linting"
pipelines:
pull-requests:
develop:
- step: *linting
master:
- step: *linting
# TODO: build docker image
branches:
nunit:
# - step: *linting
- step: &run-test
name: Test and upload report
script:
# Run test
- cd ./Nunit/PrimeService && dotnet restore
- cd .. && dotnet sln add PrimeService/PrimeService.csproj
- cd ./PrimeService.Tests && dotnet restore
- cd .. && dotnet sln add PrimeService.Tests/PrimeService.Tests.csproj
- dotnet test --logger:"nunit;LogFilePath=test-result.xml"
# Upload the report
- export token=$(curl 'https://agiletest.atlas.devsamurai.com/api/apikeys/authenticate' -X POST -H 'Content-Type:application/json' --data '{"clientId":"'"$CLIENT_ID"'","clientSecret":"'"$CLIENT_SECRET"'"}' | tr -d '"')
- echo $token
- curl -X POST -H "Content-Type:application/xml" -H "Authorization:JWT $token" --data-binary "@PrimeService.Tests/test-result.xml" "https://api.agiletest.app/ds/test-executions/nunit?projectKey=$PROJECT_KEY"
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 document.
Use AgileTest CLI
image: mcr.microsoft.com/dotnet/sdk
options:
docker: true
definitions:
steps:
- step: &linting
name: Linting
caches:
- dotnetcore
script:
- echo "linting"
pipelines:
pull-requests:
develop:
- step: *linting
master:
- step: *linting
branches:
nunit:
- step: &run-test
name: Run test
script:
- cd ./Nunit/PrimeService && dotnet restore
- cd .. && dotnet sln add PrimeService/PrimeService.csproj
- cd ./PrimeService.Tests && dotnet restore
- cd .. && dotnet sln add PrimeService.Tests/PrimeService.Tests.csproj
- dotnet test --logger:"nunit;LogFilePath=test-result.xml"
artifacts:
- Nunit/PrimeService.Tests/*.xml
- step: &upload-report
name: Upload report to AgileTest using cli
image: ghcr.io/agiletestapp/agiletest-cli:latest
script:
- |
agiletest \
--base-auth-url $BASE_AUTH_URL \
--base-url $BASE_URL \
--client-id $CLIENT_ID \
--client-secret $CLIENT_SECRET \
test-execution import --framework-type nunit \
--project-key $PROJECT_KEY Nunit/PrimeService.Tests/test-result.xml
In this file, we configure 2 steps, run-test and upload-report. Each step runs in a container of different image. For run-test, we use dotnet image, but in upload-report, the docker image is actually the one built for Agile Test CLI.
In run-test step, we run the automation test scripts and the process yields the report. The report is then pushed to pipeline artifact in order to be used for the later step. Next, in upload-report step, the report is uploaded to AgileTest by using AgileTest CLI. Below is the command used for the task.
agiletest --base-auth-url $BASE_AUTH_URL \
--base-url $BASE_URL \
--client-id $CLIENT_ID \
--client-secret $CLIENT_SECRET \
test-execution import --framework-type nunit \
--project-key $PROJECT_KEY Nunit/PrimeService.Tests/test-result.xml
As you can see, there are 2 additional variables, BASE_AUTH_URL and BASE_URL, which we will add to our pipeline variable collection.
Variables | Description | Value |
---|---|---|
BASE_AUTH_URL | Base URL used for requesting authenticating token | https://agiletest.atlas.devsamurai.com |
BASE_URL | Base URL to submit your report to | https://api.agiletest.app |

Additional pipeline variables
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!