> ## Documentation Index
> Fetch the complete documentation index at: https://docs.mergeguide.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Bitbucket

> Connect Bitbucket so MergeGuide evaluates pull requests and reports results.

MergeGuide integrates with **Bitbucket Cloud** to evaluate pull requests. When a PR
is opened or updated, MergeGuide checks the changes against your policies and
reports the result back on the pull request.

## How it works

Once connected, MergeGuide listens for pull request events from your Bitbucket
repository. On a relevant event it evaluates the changed code and posts the result
to the PR. Blocking findings hold the merge until they're resolved.

## Connect Bitbucket

<Steps>
  <Step title="Add the repository in the dashboard">
    In [portal.mergeguide.com](https://portal.mergeguide.com), open
    **Repositories** and connect your Bitbucket repository.
  </Step>

  <Step title="Configure the webhook">
    Add a webhook in your Bitbucket repository settings for pull request events,
    using the URL and secret MergeGuide provides. The secret is used to verify that
    webhook requests genuinely come from Bitbucket.
  </Step>

  <Step title="Open a pull request">
    Open or update a PR. MergeGuide evaluates the change and reports the result on
    the pull request.
  </Step>
</Steps>

## Run in Bitbucket Pipelines

You can also run MergeGuide as a pipeline step. Install the CLI and run a check:

```yaml bitbucket-pipelines.yml theme={null}
pipelines:
  pull-requests:
    '**':
      - step:
          name: MergeGuide policy check
          image: python:3.11
          script:
            - pip install mergeguide
            - mergeguide check . --fail-on-warning
```

See [CI/CD patterns](/integrations/ci-cd-patterns) for the general pipeline recipe.

## Block merges on findings

Require the MergeGuide check to pass before a PR can merge using Bitbucket's merge
checks in your repository settings. See [Set up the PR gate](/install/pr-gate).

## Next steps

<CardGroup cols={2}>
  <Card title="PR gate" icon="code-pull-request" href="/install/pr-gate">
    Block merges on blocking findings.
  </Card>

  <Card title="CI/CD patterns" icon="arrows-spin" href="/integrations/ci-cd-patterns">
    Wire MergeGuide into any pipeline.
  </Card>
</CardGroup>
