# Bitbucket

BugBug can run tests from Bitbucket Pipelines using BugBug Command Line Interface.

Use this integration when you want Bitbucket to run BugBug tests before deployment or as part of your pull request workflow.

Keep in mind that cloud runs from CI/CD integrations are available on paid plans. More information about pricing can be found here: <https://bugbug.io/pricing/>

### Get your API token and suite ID

1. Go to the **Integrations** page.
2. Open the **CLI** tab.
3. Copy your API token or CLI setup command.
4. Find the suite or test you want to run.
5. Open its menu and select **Run via CLI or webhook**.
6. Copy the test ID or suite ID.

Store the API token as a Bitbucket repository variable. Do not commit it to the repository.

### Example Bitbucket pipeline

Add a step like this to `bitbucket-pipelines.yml`:

```yaml
image: node:20

pipelines:
  default:
    - step:
        name: BugBug tests
        script:
          - npm install -g @testrevolution/bugbug-cli
          - bugbug config set-token "$BUGBUG_API_TOKEN"
          - bugbug remote run suite <suite-id>
```

Set `BUGBUG_API_TOKEN` in **Repository settings > Repository variables** in Bitbucket.

### Use Public API or incoming webhooks

Use the Public API if your Bitbucket pipeline needs advanced control, such as checking run status, stopping runs, or downloading reports.

Use incoming webhooks if Bitbucket only needs to trigger a run with one `POST` request.

BugBug does not require a native Bitbucket OAuth connection for this flow.


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.bugbug.io/integrations/bitbucket.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
