# GitLab CI

> Run the Testsigma trigger script from a GitLab CI job so tests run on every push.

GitLab pipelines run the Testsigma [shell script](https://testsigma.com/docs/v2/integrations/ci-cd/shell-script/) as a build job. Commit the script to the project, call it from the CI/CD configuration file, and every pipeline run triggers the test plan.

## Prerequisites

- A GitLab account, a Testsigma API key, and the test plan ID.

## Configure the pipeline

1. **Log in**: Sign in to your GitLab account.

2. **Create a project**: Click **New project** and create a blank project or a CI/CD project, as you prefer. On the create project page, enter the details and click **Create project**.

3. **Open the jobs page**: Navigate to **CI/CD** and click **Jobs**.

4. **Create the configuration file**: Click **Create CI/CD Configuration file** to create a YML file, or use this sample job:

   ```yaml title=".gitlab-ci.yml"
   stages:
    - build
   build-code-job:
    stage: build
    script:
    - echo "Calling Shell Script of testsigma"
    - pwd
    - ls -la
    - chmod a+x gitlabcicd.sh
    - ./gitlabcicd.sh
   ```

5. **Set the script inputs**: The [shell script](https://testsigma.com/docs/v2/integrations/ci-cd/shell-script/) (`gitlabcicd.sh` here) triggers the test plan and fetches the run result. In it, replace the `TESTSIGMA_API_KEY` and `TESTSIGMA_TEST_PLAN_ID` values. The key comes from [Settings > API Keys](https://testsigma.com/docs/v2/settings/developers/), the plan ID from **Test Plans > CI/CD Integrations**.

6. **Commit**: Click **Commit changes**. The job starts to run, and the test plan configured in the script starts with it.

Place the script in the same project and call it from the YML file, or fetch it from an external source by giving the appropriate path.

Any bash runner works with this YML as-is, the Docker runner included. On a different runner such as PowerShell, modify the YML so it executes there and use PowerShell 7 or above.

## Check the result

Once the job completes, the execution report is saved as an XML file at the path set in the shell script. The job's detail page shows the run outcome.
