|
| 1 | +--- |
| 2 | +title: 'GitLab Integration with Test Management by Testsigma' |
| 3 | +page_title: 'GitLab Integration with Test Management by Testsigma' |
| 4 | +metadesc: 'Integrate GitLab with Test Management by Testsigma to automate test executions & generate test reports through CI/CD pipelines | GitLab Integration with TMS by Testsigma' |
| 5 | +noindex: false |
| 6 | +order: 14.6 |
| 7 | +page_id: 'Gitlab-ci-integration-with-test-management-by-testsigma' |
| 8 | +warning: false |
| 9 | +contextual_links: |
| 10 | + - type: section |
| 11 | + name: 'Contents' |
| 12 | + - type: link |
| 13 | + name: 'Prerequisites' |
| 14 | + url: '#prerequisites' |
| 15 | + - type: link |
| 16 | + name: 'Set Testsigma Secrets in GitLab' |
| 17 | + url: '#set-testsigma-secrets-in-gitlab' |
| 18 | + - type: link |
| 19 | + name: 'Configure the GitLab Pipeline' |
| 20 | + url: '#configure-the-gitlab-pipeline' |
| 21 | + - type: link |
| 22 | + name: 'Triggering the Pipeline' |
| 23 | + url: '#triggering-the-pipeline' |
| 24 | +--- |
| 25 | + |
| 26 | +<br> |
| 27 | + |
| 28 | +**Integrate GitLab with Test Management by Testsigma and automate your test runs and generate test reports.** |
| 29 | + |
| 30 | +--- |
| 31 | + |
| 32 | +Integrate GitLab with Test Management by Testsigma to automate test executions and generate test reports through CI/CD pipelines. This article discusses integrating GitLab with Test Management by Testsigma. |
| 33 | + |
| 34 | +--- |
| 35 | + |
| 36 | +> ## **Prerequisites** |
| 37 | +> Before you begin, ensure the following: |
| 38 | +> - You have a **GitLab** account and a connected project repository. |
| 39 | +> - A project and at least one test run exist in Test Management by Testsigma. |
| 40 | +> - You have an API token from Test Management by Testsigma. |
| 41 | +> - Your test results are generated in JUnit XML format (for example, reports/junit.xml) |
| 42 | +
|
| 43 | +--- |
| 44 | + |
| 45 | +## **Set Testsigma Secrets in GitLab** |
| 46 | + |
| 47 | +To allow GitLab to communicate securely with Testsigma: |
| 48 | + |
| 49 | +1. Go to your project in GitLab |
| 50 | + |
| 51 | +2. Navigate to **Settings > CI/CD > Variables** and click **Expand**. |
| 52 | + |
| 53 | +3. Add the following environment variables: |
| 54 | + - **TESTSIGMA\_API\_TOKEN** |
| 55 | + - **TESTSIGMA\_PROJECT\_ID** |
| 56 | + - **TESTSIGMA\_RUN\_ID** |
| 57 | + |
| 58 | +4. Click **Save** changes. |
| 59 | + |
| 60 | +--- |
| 61 | + |
| 62 | +## **Configure the GitLab Pipeline** |
| 63 | + |
| 64 | +In your project repository, create or update the **.gitlab-ci.yml** file in the root directory with the following configuration: |
| 65 | + |
| 66 | +```yml |
| 67 | +stages: |
| 68 | + - upload |
| 69 | + |
| 70 | +upload_testsigma: |
| 71 | + stage: upload |
| 72 | + image: curlimages/curl:8.10.1 |
| 73 | + only: |
| 74 | + - main |
| 75 | + script: |
| 76 | + - 'set -eu' |
| 77 | + - 'echo "Looking for reports/junit.xml ..."' |
| 78 | + - 'test -f reports/junit.xml || { echo "File not found: reports/junit.xml"; exit 1; }' |
| 79 | + - 'echo "Uploading JUnit XML to Testsigma..."' |
| 80 | + - 'curl --fail --show-error --location \ |
| 81 | + --header "Authorization: Bearer ${TESTSIGMA_API_TOKEN}" \ |
| 82 | + --form "junit_xml=@reports/junit.xml" \ |
| 83 | + "https://test-management.testsigma.com/api/v1/projects/${TESTSIGMA_PROJECT_ID}/junit-import/test-run/${TESTSIGMA_RUN_ID}"' |
| 84 | + - 'echo "Upload complete."' |
| 85 | +``` |
| 86 | +
|
| 87 | +This configuration performs the following actions: |
| 88 | + - Runs when you push to the main branch. |
| 89 | + - Verifies that the JUnit XML file exists. |
| 90 | + - Upload the test results to your specified Testsigma project and test run. |
| 91 | +
|
| 92 | +[[info | **NOTE**:]] |
| 93 | +| - Replace **TESTSIGMA\_PROJECT\_ID** in the curl command with your Project ID. You can find it in your project URL: https://test-management.testsigma.com/ui/projects/{Project_ID}/ |
| 94 | +| - Replace **TESTSIGMA\_RUN\_ID** in the curl command with your **Test Run ID**, available in the **Test Run URL**: https://test-management.testsigma.com/ui/test_runs/{Run_ID}/ |
| 95 | +| - Replace **TESTSIGMA\_API\_TOKEN** with your Testsigma API token stored in GitLab CI/CD variables. |
| 96 | +| - Ensure the JUnit report path (reports/junit.xml) matches your actual test report file location. |
| 97 | +
|
| 98 | +--- |
| 99 | +
|
| 100 | +## **Triggering the Pipeline** |
| 101 | +
|
| 102 | +1. Commit and push your changes to the repository connected to GitLab. |
| 103 | +
|
| 104 | +2. GitLab will run the workflow. |
| 105 | +
|
| 106 | +3. After completion, the corresponding test run in Test Management by Testsigma will be automatically updated with the test execution results. |
| 107 | +
|
| 108 | +--- |
0 commit comments