Site admins can sync Git repositories hosted on Bitbucket Cloud with Sourcegraph so that users can search and navigate the repositories.
To connect Bitbucket Cloud to Sourcegraph:
- Go to Site admin > Manage code hosts > Add repositories.
- Select Bitbucket.org.
- Configure the connection to Bitbucket Cloud using the action buttons above the text field. Additional fields can be added using Cmd/Ctrl+Space for auto-completion. See the configuration documentation below.
- Press Add repositories.
Currently, all repositories belonging to the user configured will be synced.
In addition, there is one more field for configuring which repositories are mirrored:
teams
A list of teams (workspaces) that the configured user has access to whose repositories should be synced.exclude
A list of repositories to exclude, which takes precedence over theteams
field.
Bitbucket Cloud code host connections can be configured with either a username and app password combination, or with workspace access tokens.
- Visit your Bitbucket account settings page.
- Navigate to App passwords.
- Select Create app password.
- Give your app password a label.
- Select the
Projects: Read
permission.Repositories: Read
should automatically be selected. - Press Create.
Use the newly created app password and your username to configure the Bitbucket Cloud connection:
{
"url": "https://bitbucket.org",
"username": "USERNAME",
"appPassword": "<PASSWORD>",
// ... other settings
}
- Visit the Bitbucket Cloud workspace settings page of the workspace you want to create an access token for.
- Navigate to Security > Access tokens.
- Press Create workspace access token.
- Give your access token a name.
- Select the
Projects: Read
permission.Repositories: Read
should automatically be selected. - Press Create.
Use the newly created access token to configure the Bitbucket Cloud connection:
{
"url": "https://bitbucket.org",
"accessToken": "ACCESS_TOKEN",
// ... other settings
}
Sourcegraph clones repositories from your Bitbucket Cloud via HTTP(S), using the username
and appPassword
required fields you provide in the configuration.
Read about how Bitbucket Cloud applies rate limits here.
When Sourcegraph encounters rate limits on Bitbucket Cloud, it will retry the request with exponential back-off, until 5 minutes have passed. If the connection is still being rate limited after 5 minutes, the request will be dropped.
To configure Bitbucket Cloud as an authentication provider (which will enable sign-in via Bitbucket Cloud), see the authentication documentation.
Prerequisite: Add Bitbucket Cloud as an authentication provider.
Then, add or edit a Bitbucket Cloud connection as described above and include the authorization
field:
{
// The URL used to set up the Bitbucket Cloud authentication provider must match this URL.
"url": "https://bitbucket.com",
"username": "horsten",
"appPassword": "$APP_PASSWORD",
// ...
"authorization": {}
}
NOTE: It can take some time to complete full cycle of repository permissions sync if you have a large number of users or repositories. See sync duration time for more information.
Bitbucket Cloud connections support the following configuration options, which are specified in the JSON editor in the site admin "Manage code hosts" area.
Using the webhooks
property on the external service has been deprecated.
Please consult this page in order to configure webhooks.