Skip to main content
Skip table of contents

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.

image-20250117-071439.png

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.

  1. Add a step of Maven type and name it “Build & Test”.

  2. Set Goal = test.

image-20250116-185900.png

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.

  1. Add a step of Script type and name it “Upload test result”.

  2. 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.

BASH
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%"
image-20250117-044726.png

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.

  1. Add a step of Maven type and name it “Build & Test”.

  2. Set Goal = test.

  3. Set Artifact = **/TEST-*.xml or name of the report files after the testing phase finishes.

Learn more about wildcards in TeamCity. Wildcard Support | TeamCity

Screen Shot 2025-01-17 at 15.15.02-20250117-081510.png

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.

  1. Tick Job 1 checkbox in Dependencies section.

Screen Shot 2025-01-17 at 15.16.53-20250117-081704.png

Job 2 configuration

  1. Add a step of Script type and name it “Upload test result”.

  2. 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.

BASH
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
  1. Switch Run in Docker on and select Dockerfile. Fill in Describe in command line text area the content below and save.

DOCKER
# 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.

image-20250117-082446.png

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!

JavaScript errors detected

Please note, these errors can depend on your browser setup.

If this problem persists, please contact our support.