# Bitbucket Pipelines

> Trigger Testsigma test plans from a Bitbucket pipeline step on every push to the repository.

Bitbucket Pipelines triggers Testsigma test plans from a step in `bitbucket-pipelines.yml`. The step runs the [shell script](https://testsigma.com/docs/v2/integrations/ci-cd/shell-script/), which starts the plan and fetches the JUnit XML report.

## Prerequisites

- An [API key](https://testsigma.com/docs/v2/settings/developers/) and the test plan ID, set in the script (`testsigma-cicd.sh`).

## Configure the pipeline

1. **Open Pipelines**: on your project, navigate to **Repository > Pipelines**.

2. **Create the pipeline**: click **Create your first pipeline** and select **Starter pipeline**.

3. **Create the job**: use this YML sample:

    ```yaml title="bitbucket-pipelines.yml"
    pipelines:
      default:
        - parallel:
          - step:
              name: 'Build and Test'
              script:
                - echo "Your build and test goes here..."
                - echo "Calling Shell Script of testsigma"
                - chmod a+x testsigma-cicd.sh
                - ./testsigma-cicd.sh
    ```

4. **Set the script inputs**: in the shell script, provide the **Test Plan ID** and **API Key**.

5. **Run the job**: click **Commit**. Once the job completes, the execution report is available as an XML report at the path set in the shell script.

The shell script can live in the same project and be called from the YML file, or come from an external source if you provide the appropriate path.

Any bash runner works with this YML file as is (for example, the Docker runner). A PowerShell runner needs a modified YML file, and PowerShell must be version 7 or above.
