GitLab Configuration

Pre-requisites

  • 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 gitlab-ci.yml file should have been created in Repository > Files in GitLab. The following is an example of yml file.

    GitLab repository view showing the .gitlab-ci.yml file with a simple job definition that echoes environment and parameter variables in the script section.

Generate tokens for Pipeline triggers

Follow the steps mentioned below to generate a token in GitLab. For detailed guidance, see GitLab documentation on adding a new trigger.

Steps:

  1. Go to your project in GitLab.

  2. On the left sidebar, select Settings, and then CI/CD.

  3. Expand Pipeline triggers.

  4. Enter a description of the project’s trigger.

  5. Click the Add trigger button.

    GitLab project settings under the CI/CD section showing the Pipeline triggers page where a new trigger named QTM4J_CICD is added with token, description, owner, and last used information.

Construct URL

The following is an example of constructing the URL to trigger a build in GitLab.

https://gitlab.com/api/v4/projects/<project_id>/trigger/pipeline

If your Project ID is 44922697 (as per the example shown in the image below), then the URL to trigger the build would be:

https://gitlab.com/api/v4/projects/44922697/trigger/pipeline

GitLab project overview page displaying project details for “Demo,” highlighting the Project ID number 44922697 along with commit count, branch, tags, storage size, and environment information.

CI/CD Rule Configuration in QTM

The following are examples of triggering the build without parameters and with query parameters.

CI/CD Rule Without Parameters

CI/CD rule configuration screen in QMetry showing details for a GitLab QTM rule setup. The Webhook URL, headers, and HTTP method (POST) are defined, with the “Authorization” header masked and no parameters or webhook body specified.

CI/CD Rule With Query Parameters

CI/CD rule configuration screen in QMetry showing setup for a GitLab QTM rule with parameters. The Webhook URL, authorization header, and POST method are defined. Query parameters include ref: main, variable [parameter]: QTM, and variable [environment]: Chrome.

After creating the CI/CD rule in , you can trigger a pipeline job in GitLab.

The pipeline gets triggered successfully.

Publication date: