GitLab runner should have been installed on the machine before triggering the build to GitLab. Refer to https://docs.gitlab.com/runner/ for more details on GitLab Runner.
The source code should have been hosted on GitLab.
The gitlab-ci.yml file should have been created in Repository > Files in GitLab.
Download the sample file
Note: The example file used in the article only shows the “deploy” stage scripted. It assumes that the GitLab runners are configured and test-result file(s) are already present in the GitLab repository.
Set up the GitLab Pipeline
Steps to set up the GitLab pipeline that executes an automated tests project and sends the results to QMetry.
(A) Parameters (except testcase_fields and testsuite_fields) can be added directly to the configuration file gitlab-ci.yml after uncommenting (removing `#` from the variables).
The parameters testcase_fields and testsuite_fields parameters need JSON objects as their inputs, they cannot be added to the configuration file gitlab-ci.yml due to their technical limitations.
Parameters skipWarning and is_matching_required should have some values. They can either be omitted entirely or have some value. In case you want to omit these fields, remove the highlighted lines from the configuration file gitlab-ci.yml.
(B) Parameters can be added as values of variables before running the pipeline from GitLab UI.
(C) Parameters can be added as values of environment variables.
Using Body Parameters in gitlab-ci.yml
The parameters and their corresponding GitLab variables for the pipeline:
Update Configuration Variables for Authentication
Go to Settings > CI/CD > Variables to replace variable values in the file content using your details. You can store values for API Key, Project Name, and other parameters.
The API_KEY refers to 'QMetry Automation API' which you can find in QMetry Testmanagement (QMetry > Integration > Automation API).
Along with INSTANCE_URL and API_KEY, set default values for fields skipWarning to “0” and is_matching_required to “false” as their value cannot be empty.
Set project-key in the PROJECT variable, file-name(along with extension) in the FILE_NAME variable, and supported testing type (JUNIT, CUCUMBER, etc.) in the TESTING_TYPE variable under "variables" in the pipeline configuration i.e. gitlab-ci.yml file.
In order to upload multiple files, repeat the `cURL` request and set file names under different variables such as FILE_NAME_1, FILE_NAME_2, etc., and set them into the requests accordingly.
For more information regarding supported file types and testing frameworks, refer to QMetry Automation API.
You can go ahead and initiate the pipeline once all the required parameters are defined and the configuration is done.
1. Go to Build > Pipelines and click on the Run Pipeline.
You can change the variable values at run time.
2. Click on the Run Pipeline button.
The job is initiated.
Verify the Progress in QMetry
In QMetry, you can view the progress of the automation result upload to QMetry.
Once the process of uploading the automation test results is over, the test cases and test suites are created in QMetry.