TeamCity
TeamCity is a powerful Continuous Integration/Continuous Deployment (CI/CD) server developed by JetBrains. It automates software build, test, deployment, and reporting processes. In this document, we will show you how to integrate AgileTest with CircleCI.
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 TeamCity
Unlike GitHub, GitLab, or Bitbucket, CircleCI is solely a CI/CD platform. It doesn’t have source repositories or version control system. That’s why when using CI/CD platform, users need to connect it with other source repositories.
To learn more about how to setup a project or a pipeline in TeamCity, please refer to this document: Getting Started with TeamCity.
In this example below, we integrate a TeamCity pipeline with a GitHub repository.
Open the pipeline settings and add these 2 secret parameters CLIENT_ID and CLIENT_SECRET with respective Client id and Client secret you have acquired earlier. Then add PROJECT_KEY variable with the project key in your Jira instance.

Pipeline environment setting
Next, create a job that could achieve your use case. There could be more than one way for you to setup a pipeline in TeamCity. However, in order to simplify the process we will configure the pipeline in 2 separate steps or jobs.
Upload test result
Use API
We will create a two-step job to help upload test result to Agile Test.
Step 1: Build and run test
In step 1, the pipeline runs tests and yield the test reports. The reports are generated and stored in target/surefile-reports directory.
Add a step of Maven type and name it “Build & Test”.
Set Goal =
test
.

Step 1 configuration
Step 2: Upload test result to Agile Test via API
In step 2, the pipeline uploads test reported (stored in Artifact in the last job) to Agile Test using curl to send API requests.
Add a step of Script type and name it “Upload test result”.
In Script content field, add the scrip below and save. All parameters encapsulated in
%
will be replaced with preconfigured secrets and parameters on pipeline run.
cd target/surefire-reports
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 '"')
curl -X POST \
-H "Content-Type:application/xml" \
-H "Authorization:JWT $token" \
--data-binary "@TEST-calculateTest.xml" "https://api.agiletest.app/ds/test-executions/junit?projectKey=%PROJECT_KEY%"

Step 2 configuration
Use AgileTest CLI
Unlike API methods, this approach necessitates dividing the process into two discrete jobs.
Job 1: Build and run test
In job 1, the pipeline runs tests and yield the test reports. Then it uploads test reports to Artifact registry.
Add a step of Maven type and name it “Build & Test”.
Set Goal =
test
.Set Artifact =
**/TEST-*.xml
or name of the report files after the testing phase finishes.
Learn more about wildcards in TeamCity. Wildcard Support | TeamCity

Job 1 configuration
Job 2: Upload test result to Agile Test via API
In job 2, the pipeline uploads test reported (stored in Artifact in the last job) to Agile Test using curl to send API requests.
Tick Job 1 checkbox in Dependencies section.

Job 2 configuration
Add a step of Script type and name it “Upload test result”.
In Script content field, add the command below and save. All parameters encapsulated in
%
will be replaced with preconfigured secrets and parameters on pipeline run.
cd target/surefire-reports
agiletest --client-id %CLIENT_ID% --client-secret %CLIENT_SECRET% \
test-execution import \
--framework-type junit --project-key %PROJECT_KEY% \
TEST-calculateTest.xml
Switch Run in Docker on and select Dockerfile. Fill in Describe in command line text area the content below and save.
# Use official AgileTest CLI image as base
FROM ghcr.io/agiletestapp/agiletest-cli:latest
# Copy application code
COPY . .
At this stage, your step should look like this.

Upload test result step in Job 2
Now your pipeline is ready to use 😉
Should you need any assistance or further AgileTest inquiries, contact here!