Gitlab CI#

PRO

Goals#

  • Run tests in Gitlab CI.

  • Receive SLA results automatically.

Solution#

  1. Create a test.

  2. Configure SLA.

  3. Download the .gitlab-ci.yml file and paste it to the root of your GitLab repository. For more information, see Tutorial: Create and run your first GitLab CI/CD pipeline and .gitlab-ci.yml keyword reference.

  4. In the file, enter the values of the variables:

    • API_TOKEN.value. The API token.

    • TEST_ID.value. The unique identifier of the test. To find the ID, follow these steps:

      1. Go to the Tests page.

      2. Select the test. The ID of the test is displayed in the address bar: testId

    • TEST_VERSION_ID.value. The unique identifier of the test’s version. If the parameter isn’t specified, the latest test’s version will run. To find the version ID, follow these steps:

      1. Go to the Test runs page.

      2. Select the test run.

      3. Click Test. The ID of the test’s version is displayed in the address bar: testVersionId

  5. Save the file.

When you commit the file to your repository, the runner runs your jobs. The job results are displayed in a pipeline.

Note

If the pipeline displays curl: (22) The requested URL returned error: 404, make sure that the values of the variables in the .gitlab-ci.yml file are specified correctly.

The .gitlab-ci.yml script#

The .gitlab-ci.yml file contains the script that:

  1. Sends a request to run the test.

  2. Gets the test run ID from the response.

  3. Checks the SLA status every 30 seconds. If the SLA status has a value other than PROCESSING, then the script sends a request to get the results of the SLA test run.

  4. Checks the SLA status. If the SLA status is FINISHED, then the script gets the SLA result from the response.