Skip to main content
Looking for docs on Bitbucket Cloud? See this doc.
If you’re not familiar with Sourcebot connections, please read that overview first.

Examples

Requires a token to be set in order to access private repositories.

Authenticating with Bitbucket Data Center

In order to index private repositories, you’ll need to provide a HTTP Access Token. Tokens can be scoped to a user account, a project, or an individual repository. Only repositories visible to the token will be able to be indexed by Sourcebot.
If permission syncing is enabled, the token must have Repository Admin permissions so Sourcebot can read repository-level user permissions.
User account tokens grant access to all repositories the user can access. Because these are tied to a specific user account, you must also set the user field to that user’s username.
  1. In Bitbucket Data Center, navigate to your profile → Manage accountHTTP access tokens and click Create token. Give it a name and grant it Project read and Repository read permissions.
  2. Add the user (your Bitbucket username) and token properties to your connection config:
  1. Pass this environment variable each time you run Sourcebot:

Rate limiting

Bitbucket Data Center supports rate limiting to protect instance stability. Rate limiting applies to HTTP requests with basic or bearer authentication, which includes the REST API calls Sourcebot makes to sync repositories. If rate limiting is enabled on your instance, Sourcebot may receive HTTP 429 (Too Many Requests) errors during sync. To prevent this, add a rate limiting exemption for the user (service account) whose token is used in your connection config. To add an exemption:
  1. In Bitbucket Data Center, go to AdministrationRate limitingExemptions tab.
  2. Click Add exemption and find the service account user.
  3. Select Allow unlimited requests (recommended) or set a custom token bucket size and refill rate appropriate for your sync volume.
  4. Click Save.
Bitbucket Data Center rate limiting exemptions tab showing a user with unlimited requests

Troubleshooting

If you’re seeing errors like TypeError: fetch failed when fetching repo info, it may be that Sourcebot is refusing to connect to your self-hosted Bitbucket instance due to unrecognized SSL certs. Try setting the NODE_TLS_REJECT_UNAUTHORIZED=0 environment variable or providing Sourcebot your certs through the NODE_EXTRA_CA_CERTS environment variable.

Schema reference

schemas/v3/bitbucket.json