# Bitbucket

[<mark style="color:blue;">Bitbucket</mark>](https://bitbucket.org/) is a Git-based source code repository hosting service.

Route detailed alerts from Bitbucket to the right users in Squadcast.

### How to integrate Bitbucket with Squadcast

### In Squadcast: Using Bitbucket as an Alert Source

1. Navigate to **Services** -> **Service Overview** -> select or search for your Service. Expand the accordion -> In the Alert Sources section, click **Add**.

<figure><img src="https://1574591692-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F8TaWz01jmUJl58p4ZVel%2Fuploads%2Fgit-blob-4fbd74e7ca0b30173c47a1d58ed6a0804a0465aa%2FAlert_Sources.png?alt=media&#x26;token=aaca6610-9d18-4dd4-9cf5-320042f326f1" alt="How to configure Bitbucket integration in Squadcast" width="563"><figcaption></figcaption></figure>

2\. Select **Bitbucket**. Copy the displayed **Webhook URL** to [configure](#in-squadcast-using-bitbucket-as-an-alert-source) it within **Bitbucket**. Finish by clicking **Add Alert Source** -> **Done**.

<figure><img src="https://1574591692-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F8TaWz01jmUJl58p4ZVel%2Fuploads%2Fgit-blob-31c2922826b54062052c33153d336bea0e207fc0%2FBitbucket%20.png?alt=media&#x26;token=20d78f68-88dd-46bc-9df5-6dd79810f211" alt="Steps to add Bitbucket integration to a service in Squadcast" width="563"><figcaption></figcaption></figure>

{% hint style="warning" %} <mark style="color:orange;">**Important**</mark>**:**

When an alert source turns <mark style="color:green;">Active</mark>, it’ll show up under Configured Alert Sources. You can either generate a test alert from the integration or wait for a real-time alert to be generated by the Alert Source.\
\
An Alert Source is <mark style="color:green;">active</mark> if there is a recorded incident via that Alert Source for the Service.
{% endhint %}

### In Bitbucket: Set up a Webhook for Squadcast

**(1)** Open the repository where you want to add the Webhook for Squadcast and click on **Repository settings**

<figure><img src="https://1574591692-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F8TaWz01jmUJl58p4ZVel%2Fuploads%2Fgit-blob-d8e147a3083de3fef8e5733c3e2fc204f83bddca%2Fbitbucket_2.png?alt=media&#x26;token=78422e9c-7f5a-4cde-9144-7ad249c9c49a" alt="Setting up Squadcast Webhook in Bitbucket: Access repository settings to add the Webhook for Squadcast integration" width="305"><figcaption></figcaption></figure>

**(2)** From the links on the **Settings** page, click the **Webhooks** link

<figure><img src="https://1574591692-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F8TaWz01jmUJl58p4ZVel%2Fuploads%2Fgit-blob-3d37b7d16220526b595e2f707d4e8c7619aec727%2Fbitbucket_3.png?alt=media&#x26;token=059a93d5-bd43-4216-a139-4ba1eb43c377" alt="Setting up Squadcast Webhook in Bitbucket: Access repository settings to add the Webhook for Squadcast integration" width="304"><figcaption></figcaption></figure>

**(3)** Select the **Add webhook** button to create a Webhook for the repository

<figure><img src="https://1574591692-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F8TaWz01jmUJl58p4ZVel%2Fuploads%2Fgit-blob-0e05bba68d6b32140e7412b2cae909f5c4eb86d2%2Fbitbucket_4.png?alt=media&#x26;token=26c9b802-87ee-468e-a503-7761581a6da7" alt="Setting up Squadcast Webhook in Bitbucket: Select the Add webhook button to create a Webhook for the repository" width="375"><figcaption></figcaption></figure>

**(4)** In the **Add new webhook** page, enter a **Title**, paste the previously copied Webhook URL from Squadcast and select the below in the **Triggers** field:

* `Repository push`
* `Pull request created`
* `Pull request merged`

Click on **Save**

<figure><img src="https://1574591692-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F8TaWz01jmUJl58p4ZVel%2Fuploads%2Fgit-blob-58260deb312f942dec37f164a4e085f9e8328756%2Fbitbucket_5.png?alt=media&#x26;token=c878d9a5-3a68-4c77-8196-352b768eb8b6" alt="Adding Squadcast Webhook in Bitbucket: Enter title, paste URL, and select triggers in the Add new webhook page" width="375"><figcaption></figcaption></figure>

{% hint style="info" %} <mark style="color:blue;">**Note**</mark>**:**

This integration supports the below events:

* `Repository push`
* `Pull request created`
* `Pull request merged`
  {% endhint %}

{% hint style="info" %} <mark style="color:blue;">**Note**</mark>:\
For the event-type `Issue`, Integrate with our [Jira-cloud](https://support.squadcast.com/docs/jira-cloud-alert-source) as an alert source integration since Bitbucket uses Jira to create and manage issues. This way, every time you create an issue in Bitbucket, an issue for it is created in Jira, for which an incident is triggered in Squadcast.
{% endhint %}

That is it, you are good to go!

* Every time a Push or Pull Request event occurs in Bitbucket, an incident would be created in Squadcast.
* When a Pull Request is merged in Bitbucket, the corresponding incident in Squadcast will be **automatically resolved**.

*Have any questions?* [*Ask the community*](https://community.squadcast.com/view/home)*.*
