# Travis CI

> Trigger Testsigma runs from a Travis CI build and block deployment until the tests pass.

Travis CI builds trigger Testsigma test plans through webhooks callable from any CLI tool. The build runs the [shell script](https://testsigma.com/docs/v2/integrations/ci-cd/shell-script/), waits for the tests, and checks they passed before deployment.

## Prerequisites

- A Travis CI account with connected source code management.
- A CI/CD pipeline.

## Get the API key and test plan ID

1. **Generate the key**: Navigate to **Settings > API Keys** and click **Generate API Key**. On the **Generate API Key** overlay, enter a **Key Name** and click **Generate API Key**.

2. **Copy it**: On the **API Keys** page, hover over the generated key and click **Copy API Key**. This key authenticates the remote trigger requests from Travis CI.

3. **Get the test plan ID**: Navigate to **Test Plans > Test Plan > CI/CD Integrations**. The execution ID is in the **REST API call to start Test Plan** section. It tells the script which plan to trigger.

## Update the shell script

The script lives in your code repository, on GitHub, Bitbucket, Azure, or any such platform, and carries the commands that trigger the test plan remotely. Copy the generic [shell script](https://testsigma.com/docs/v2/integrations/ci-cd/shell-script/), then set your API key and test plan ID in it.

## Configure the Travis CI pipeline

1. **Save the script**: Store it in the repository as `scripts/trigger_testsigma_tests_and_wait.sh`.

2. **Make it executable**: Run `chmod ugo+x scripts/trigger_testsigma_tests_and_wait.sh`.

3. **Commit it**: Commit the script to your repository.

4. **Call it from the build**: Add it to the `script:` phase of `.travis.yml`:

   ```yaml title=".travis.yml"
   script:
     - ./scripts/trigger_testsigma_tests_and_wait.sh
   ```

With this in place, any change to the repository triggers a build, and the build starts the tests in Testsigma. The script waits until the run completes and verifies that the result is passed.
