# Bitbucket

The Bitbucket integration connects Interlynk to your Bitbucket workspaces, enabling automated SBOM processing triggered by repository events.

***

## Purpose

* Automatically ingest SBOMs on push and pull request events from Bitbucket repositories.
* Map Bitbucket branches to Interlynk environments.

## Setup Steps

Interlynk connects to Bitbucket via OAuth.

1. Navigate to **Settings > Organization > Integrations**.
2. Click **Bitbucket**.
3. You will be redirected to Bitbucket to authorize the Interlynk application.
4. Complete the authorization.
5. After redirect, select the **Workspace** from the dropdown.
6. Click **Save**.

## Supported Events

| Event                   | Trigger                 |
| ----------------------- | ----------------------- |
| `repo:push`             | Code pushed to a branch |
| `pullrequest:created`   | New pull request opened |
| `pullrequest:fulfilled` | Pull request merged     |
| `pullrequest:updated`   | Pull request updated    |

## Required Scopes

| Scope              | Purpose                                 |
| ------------------ | --------------------------------------- |
| Repository read    | Access repository contents and metadata |
| Pull request read  | Read pull request details               |
| Webhook read/write | Register and manage webhooks            |

## Security Notes

* OAuth tokens are encrypted at rest and refreshed automatically.
* The integration only accesses repositories within the selected workspace.
* Revoke access from Bitbucket's **Personal Settings > App authorizations** if needed.

## Troubleshooting

| Issue                            | Cause                                | Resolution                                             |
| -------------------------------- | ------------------------------------ | ------------------------------------------------------ |
| No workspaces visible            | OAuth scope too narrow               | Re-authorize the Bitbucket integration                 |
| Push events not triggering       | Webhook not registered on repository | Verify workspace selection and re-save the integration |
| Token expired and not refreshing | Refresh token revoked                | Disconnect and reconnect the Bitbucket integration     |


---

# 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.interlynk.io/administration/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.
