GitLab CI/CD is a software development tool that allows organizations to implement “continuous” methodologies.
In this document, we will show you how to integrate AgileTest with it.
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 GitLab repository
In your Gitlab repository, go to Settings → CI/CD → Variables, and add the variables as follows CLIENT_ID, CLIENT_SECRET, PROJECT_KEY, BASE_AUTH_URL, and BASE_URL.
Variable screen
Ensure you untick the Project Variable option for all created variables. Otherwise, you won't be able to access them in the YAML file.
Edit variable
Variables
Description
Is secured?
Example
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
CLIENT_ID
The client id that you have requested earlier
******
CLIENT_SECRET
The client secret that you have requested earlier
******
PROJECT_KEY
Your project key
RKE
Upload test result
Here's a JUnit report example for you to experiment with:
# You can override the included template(s) by including variable overrides
# SAST customization: https://docs.gitlab.com/ee/user/application_security/sast/#customizing-the-sast-settings
# Secret Detection customization: https://docs.gitlab.com/ee/user/application_security/secret_detection/#customizing-settings
# Dependency Scanning customization: https://docs.gitlab.com/ee/user/application_security/dependency_scanning/#customizing-the-dependency-scanning-settings
# Container Scanning customization: https://docs.gitlab.com/ee/user/application_security/container_scanning/#customizing-the-container-scanning-settings
# Note that environment variables can be set in several places
# See https://docs.gitlab.com/ee/ci/variables/#cicd-variable-precedence
stages:
- test
- upload-report
tests:
stage: test
image: mcr.microsoft.com/playwright:v1.42.1-jammy
script:
- npm ci
- npm run test
artifacts:
name: test_result
paths:
- playwright-report/results.xml
upload-report:
stage: upload-report
image:
name: ghcr.io/agiletestapp/agiletest-cli:latest
entrypoint: [""]
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 junit --project-key $PROJECT_KEY \
playwright-report/results.xml
In this .gitlab-ci.yml file, we have 2 jobs named tests and upload-report. Each of them is associated in a different stage and run in a container of different docker image.
In tests job, we run the automation test scripts and the process yields the reports. Then the report is uploaded to Gitlab artifact with the name test_result. By default, all artifacts of jobs belonging to a prior stage are downloaded automatically in the next stage. As a result, in upload-report, we use AgileTest command as below to upload it onto AgileTest.
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!
JavaScript errors detected
Please note, these errors can depend on your browser setup.
If this problem persists, please contact our support.