Skip to content

Latest commit

 

History

History
112 lines (75 loc) · 4.49 KB

bitbucket_cloud.md

File metadata and controls

112 lines (75 loc) · 4.49 KB

Bitbucket Cloud

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:

  1. Go to Site admin > Manage code hosts > Add repositories.
  2. Select Bitbucket.org.
  3. 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.
  4. Press Add repositories.

Repository syncing

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 the teams field.

Configuration options

Bitbucket Cloud code host connections can be configured with either a username and app password combination, or with workspace access tokens.

Username and app password

  1. Visit your Bitbucket account settings page.
  2. Navigate to App passwords.
  3. Select Create app password.
  4. Give your app password a label.
  5. Select the Projects: Read permission. Repositories: Read should automatically be selected.
  6. 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
}

Workspace access token

  1. Visit the Bitbucket Cloud workspace settings page of the workspace you want to create an access token for.
  2. Navigate to Security > Access tokens.
  3. Press Create workspace access token.
  4. Give your access token a name.
  5. Select the Projects: Read permission. Repositories: Read should automatically be selected.
  6. Press Create.

Use the newly created access token to configure the Bitbucket Cloud connection:

{
  "url": "https://bitbucket.org",
  "accessToken": "ACCESS_TOKEN",
  // ... other settings
}

HTTPS cloning

Sourcegraph clones repositories from your Bitbucket Cloud via HTTP(S), using the username and appPassword required fields you provide in the configuration.

Rate limits

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.

Internal rate limits

See Internal rate limits

User authentication

To configure Bitbucket Cloud as an authentication provider (which will enable sign-in via Bitbucket Cloud), see the authentication documentation.

Repository permissions

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.

Configuration

Bitbucket Cloud connections support the following configuration options, which are specified in the JSON editor in the site admin "Manage code hosts" area.

[View page on docs.sourcegraph.com](https://docs.sourcegraph.com/admin/external_service/bitbucket_cloud) to see rendered content.

Webhooks

Using the webhooks property on the external service has been deprecated.

Please consult this page in order to configure webhooks.