> For the complete documentation index, see [llms.txt](https://docs.octoxlabs.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.octoxlabs.com/adapters/b/bitbucket-self-hosted.md).

# BitBucket Self Hosted

Bitbucket Self Hosted (Bitbucket Server and Data Center) runs on your own infrastructure. OctoXLabs reads projects and repositories as source code assets, and users as users, through the REST API.

## Use cases

* List repositories with their default branch (Source codes).

```
Adapters = bitbucket-self-hosted AND DefaultBranch = *
```

* List repositories that are forks (Source codes).

```
Adapters = bitbucket-self-hosted AND IsForked = true
```

## Before you begin

### Network

| Source              | Destination                       | Port               | Protocol                         |
| ------------------- | --------------------------------- | ------------------ | -------------------------------- |
| OctoXLabs connector | Bitbucket host (Domain you enter) | 443 (configurable) | HTTPS (HTTP if Is Secure is off) |

### Required permissions

| Scope or role                                     | Permission | Needed for                                                                   |
| ------------------------------------------------- | ---------- | ---------------------------------------------------------------------------- |
| Account that can browse projects and repositories | Read       | Projects, repositories, branches, pull requests, commits, forks, permissions |
| Account that can list users                       | Read       | Users (only if Fetch Users is on)                                            |

## Create credentials in BitBucket Self Hosted

{% stepper %}
{% step %}

### Choose an account

Use a Bitbucket account that can read the projects and repositories you want to inventory.
{% endstep %}

{% step %}

### Create a password

Create a personal app password for it: open **Settings > App passwords**, give it a label and select the permissions you need, for example Read under Workspaces.
{% endstep %}

{% step %}

### Use it in OctoXLabs

Enter the username and password. They are sent with Basic authentication.
{% endstep %}
{% endstepper %}

## Connection parameters

| Parameter          | Required | Type    | Default | Description                                             |
| ------------------ | -------- | ------- | ------- | ------------------------------------------------------- |
| Domain             | Yes      | String  |         | Host of the Bitbucket instance.                         |
| Port               | No       | Integer | 443     | Port of the REST API.                                   |
| Username           | Yes      | String  |         | Personal Bitbucket username.                            |
| Password           | Yes      | String  |         | Personal app password.                                  |
| Is Secure          | No       | Boolean | True    | Use HTTPS.                                              |
| Per Page           | No       | Integer | 25      | Items per request.                                      |
| Fetch Users        | No       | Boolean | False   | Collect users.                                          |
| Fetch Source Codes | No       | Boolean | True    | Collect repositories as source code assets.             |
| Thread Count       | No       | Integer | 32      | Parallel threads for repository details. Min 1, max 32. |
| Sleep Time         | No       | Integer | 0       | Delay in seconds between thread batches.                |
| Timeout            | No       | Integer | 30      | Seconds to wait for API responses.                      |
| Proxy              | No       | String  |         | Proxy as `host:port`.                                   |

## Troubleshooting

| Error message                                       | Cause                                                                                                                                  | Fix                                                                                                  |
| --------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------- |
| returned 404, treating as empty.                    | A repository file or detail endpoint does not exist. The adapter continues with empty data.                                            | No action unless data you expect is missing.                                                         |
| Request to failed after 10 attempts.                | Connection errors or timeouts on all 10 tries.                                                                                         | Check the network path, the port and the timeout.                                                    |
| There are no projects. / There are no repositories. | The test found nothing to read with this account.                                                                                      | Check the account permissions.                                                                       |
| Status Code: `, URL, Method`                        | The API answered with an unexpected HTTP status. The shared request code raises it and logs the status, URL, method and response body. | Check the URL, the credentials and the permissions listed above, then run the connection test again. |

## Change history

{% hint style="info" %}
Available starting from version 5.5.0.
{% endhint %}
