GitHub provides a comprehensive CI/CD tool that enables automated testing and deployment processes for software development projects. With GitHub Actions, developers can create workflows to build, test, and deploy code directly within their repositories.
You can follow the below video for guidance on how to integrate GitHub with AgileTest
Here are the guidance on how to integrate CI/CD tool - GitHub with AgileTest.
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 your GitHub repository
Go to your Github repository → Settings → Secrets and variables. On Secrets tab, add 2 secrets named CLIENT_ID and CLIENT_SECRET and assign them with the values of client id and client secret which you have acquired from AgileTest.
Action secrets
Similarly, on Variables tab, add 3 variables and name them BASE_AUTH_URL, BASE_URL, and PROJECT_KEY. This variable would be used to indicate which project AgileTest will create the new Test execution into.
Similarly, on Variables tab, add three variables as follows
Action variables
Variable
Description
Is secret?
Value
CLIENT_ID
The client id that you have requested earlier
CLIENT_SECRET
The client secret that you have requested earlier
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
PROJECT_KEY
Your project key
RKE
However, in case you are working with AgileTest Data Center version, you only need 3 variables as follows.
Variables
Description
Is secured?
Example
DC_TOKEN
Your Personal access token
BASE_URL
Base URL to submit your report to
PROJECT_KEY
Your project key
RKE
Upload test result
Here is a JUnit report example to experiment with.
If you need more thorough examples, please refer to our public repository for more sample projects Agile Test GitHub.
Use API
Below is a sample workflow YAML file.
AgileTest Cloud - YAML file
AgileTest Cloud - GitHub workflow YAML file
YAML
name: Agile Test Demo
# This workflow represents a set of basic End-to-End tests
on:
workflow_dispatch:
env:
BASE_URL: ${{ vars.BASE_URL }}
BASE_AUTH_URL: ${{ vars.BASE_AUTH_URL }}
CLIENT_ID: ${{ secrets.CLIENT_ID }}
CLIENT_SECRET: ${{ secrets.CLIENT_SECRET }}
PROJECT_KEY: ${{ vars.PROJECT_KEY }}
jobs:
test:
name: run test
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set up JDK 17
uses: actions/setup-java@v4
with:
java-version: "17"
distribution: "temurin"
cache: maven
- name: Build with Maven
run: mvn -B package --file pom.xml
- name: Submit test result using API
run: |
export token=$( \
curl "$BASE_AUTH_URL/api/apikeys/authenticate" \
-X POST -H 'Content-Type:application/json' \
--data '{"clientId":"'"${CLIENT_ID}"'","clientSecret":"'"${CLIENT_SECRET}"'"}' | tr -d '"'\
)
curl -X POST "$BASE_URL/ds/test-executions/junit?projectKey=$PROJECT_KEY" \
-H "Content-Type:application/xml" \
-H "Authorization:JWT $token" \
--data-binary "@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 document.
AgileTest Data center - YAML file
For Data center version, we only use 1 endpoint ds/test-executions/junit with DC_TOKEN variable instead of the token that is requested using client id and client secret. Let’s take a look at the file below!
AgileTest Data center - GitHub workflow YAML file
YAML
name: Agile Test Demo
# This workflow represents a set of basic End-to-End tests
on:
workflow_dispatch:
env:
BASE_URL: ${{ vars.BASE_URL }}
DC_TOKEN: ${{secrets.DC_TOKEN}}
PROJECT_KEY: ${{ vars.PROJECT_KEY }}
jobs:
test:
name: run test
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set up JDK 17
uses: actions/setup-java@v4
with:
java-version: "17"
distribution: "temurin"
cache: maven
- name: Build with Maven
run: mvn -B package --file pom.xml
- name: Submit test result using API
run: |
curl -X POST "$BASE_URL/ds/test-executions/junit?projectKey=$PROJECT_KEY" \
-H "Content-Type:application/xml" \
-H "Authorization:Bearer $DC_TOKEN" \
--data-binary "@target/surefire-reports/TEST-calculateTest.xml"
name: Agile Test Demo
# This workflow represents a set of basic End-to-End tests
on:
workflow_dispatch:
env:
BASE_URL: ${{ vars.BASE_URL }}
BASE_AUTH_URL: ${{ vars.BASE_AUTH_URL }}
CLIENT_ID: ${{ secrets.CLIENT_ID }}
CLIENT_SECRET: ${{ secrets.CLIENT_SECRET }}
PROJECT_KEY: ${{ vars.PROJECT_KEY }}
jobs:
test:
name: run test
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set up JDK 17
uses: actions/setup-java@v4
with:
java-version: '17'
distribution: 'temurin'
cache: maven
- name: Build with Maven
run: mvn -B package --file pom.xml
- name: Submit test result to AgileTest
run: |
docker run --rm \
-e AGILETEST_BASE_URL=$BASE_URL \
-e AGILETEST_AUTH_BASE_URL=$BASE_AUTH_URL \
-e AGILETEST_CLIENT_ID=$CLIENT_ID \
-e AGILETEST_CLIENT_SECRET=$CLIENT_SECRET \
-v ${{ github.workspace }}/target/surefire-reports:/reports \
ghcr.io/agiletestapp/agiletest-cli:latest \
test-execution import --framework-type junit --project-key $PROJECT_KEY \
/reports/TEST-calculateTest.xml
In this workflow yaml file, we have 2 main steps, namely Build with Maven and Submit test result to AgileTest:
Step 1: Run the GitHub action “Java with Maven” to build and yield the reports.
Step 2: Use Agile Test CLI, which is integrated in a docker image, to upload the test result to Agile Test application.
AgileTest Data center - YAML file
AgileTest Data center - GitHub workflow YAML file
YAML
name: Agile Test Demo
# This workflow represents a set of basic End-to-End tests
on:
workflow_dispatch:
env:
BASE_URL: ${{ vars.BASE_URL }}
DC_TOKEN: ${{ secrets.DC_TOKEN }}
PROJECT_KEY: ${{ vars.PROJECT_KEY }}
jobs:
test:
name: run test
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set up JDK 17
uses: actions/setup-java@v4
with:
java-version: '17'
distribution: 'temurin'
cache: maven
- name: Build with Maven
run: mvn -B package --file pom.xml
- name: Submit test result to AgileTest
run: |
docker run --rm \
-e AGILETEST_BASE_URL=$BASE_URL \
-e AGILETEST_DC_TOKEN=$DC_TOKEN \
-v ${{ github.workspace }}/target/surefire-reports:/reports \
ghcr.io/agiletestapp/agiletest-cli:latest \
--data-center \
test-execution import --framework-type junit --project-key $PROJECT_KEY \
/reports/TEST-calculateTest.xml
Unlike the YAML file for Cloud version, in this file, we omit CLIENT_ID, CLIENT_SECRET, and BASE_AUTH_URL. Then, we add a secret variable named AGILETEST_DC_TOKEN.
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.
View Pipeline Status
AgileTest provides a simple way to track the status of your pipeline after it has been triggered. To enable this feature, just add the following directives to your workflow file.
For Cloud version, we use the endpoint test-executions/{test_execution_id}/pipeline/history
However, if you are working with AgileTest Data center version, please use rest/agiletest/1.0/test-executions/{test_execution_id}/pipeline/history in stead.
Your file should look like this now.
YAML file that includes pipeline status update call.
YAML
name: Agile Test Demo
# This workflow represents a set of basic End-to-End tests
on:
workflow_dispatch:
env:
AGILETEST_BASE_URL: ${{ vars.AGILETEST_BASE_URL }}
AGILETEST_DC_TOKEN: ${{secrets.AGILETEST_DC_TOKEN}}
PROJECT_KEY: ${{ vars.PROJECT_KEY }}
jobs:
test:
name: run test
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set up JDK 17
uses: actions/setup-java@v4
with:
java-version: "17"
distribution: "temurin"
cache: maven
- name: Build with Maven
run: mvn -B package --file pom.xml
- name: Submit test result to Agile Test
run: |
docker run --rm \
-e AGILETEST_BASE_URL=$AGILETEST_BASE_URL \
-e AGILETEST_DC_TOKEN=$AGILETEST_DC_TOKEN \
-v ${{ github.workspace }}/target/surefire-reports:/reports \
ghcr.io/agiletestapp/agiletest-cli:latest \
--data-center \
test-execution import --framework-type junit --project-key $PROJECT_KEY \
/reports/TEST-calculateTest.xml
- name: After-Run Script
if: always()
run: |
if [ "${{ job.status }}" == "success" ]; then
RESULT="success"
else
RESULT="failed"
fi
export token=$( \
curl "$AGILETEST_AUTH_BASE_URL/api/apikeys/authenticate" \
-X POST -H "Content-Type:application/json" \
--data '{"clientId":"'"${AGILETEST_CLIENT_ID}"'","clientSecret":"'"${AGILETEST_CLIENT_SECRET}"'"}' | tr -d '"'\
)
curl "$AGILETEST_BASE_URL/ds/test-executions/${{ inputs.TEST_EXECUTION_KEY }}/pipeline/history?projectKey=$PROJECT_KEY" \
-X POST -H "Content-Type: application/json" -H "Authorization:JWT $token" \
--data '{ "repository": "'"${{ github.repository }}"'", "runId": "'"${{ github.run_id }}"'", "tool":"github", "result":"'"$RESULT"'" }'
If you include this part to your YAML file, on pipeline’s completion, a history log with pipeline status will be added on the right panel of the execution issue screen as below.
History log on pipeline status
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.