Skip to main content

Bitbucket

Overview

Connect Bitbucket to StackGuardian to source Infrastructure as Code (IaC) and Policy code from your repositories and trigger Workflow runs automatically.

To et up the connector on StackGuardian:

  1. In StackGuardian, navigate to Organization Settings → Connectors → Version control providers.
  2. Select + Connect with VCS provider.
  3. In the Connect with VCP modal, select Bitbucket as the version control provider.
  4. Choose an authentication method:
Connect with VCP modal showing Bitbucket selected with access token method

Connect with Bitbucket

Access token

To integrate Bitbucket, you first need to create an access token in Bitbucket with limited permissions (it’s possible to create an access token for a project, a repository or a workspace).

Create an access token in Bitbucket

Access token for repository

Follow these steps to create an access token for a repository in Bitbucket:

  1. Login to Bitbucket.
  2. Navigate to target repository for the access token (this repository is the only one that the access token can access).
  3. On the sidebar, select Repository Settings.
  4. Under Security, select Access Tokens.
  5. Click on Create Access Token.
  6. Provide a Name for the access token.
  7. Under Expiry, set an Expires on date (select the date which your access token will expire. Choose a long validity period, so that StackGuardian integration continues to work).
  8. Select the permissions the access token needs (for detailed descriptions of each permission, see Repository-level access token permissions):
    • Repositories: Read

repo-create-access-token

  1. Click on Create to generate the new access token.
  2. Copy the generated access token and securely store it. The access token is displayed only once and cannot be retrieved later.

repo-create-access-token

Access token for project

Follow these steps to create an access token for a project in Bitbucket:

  1. Login to Bitbucket.
  2. Navigate to target project for the access token (this project is the only one that the access token can access).
  3. On the sidebar, select Project Settings.
  4. Under Security, select Access Tokens.
  5. Click on Create Access Token.
  6. Provide a Name for the access token.
  7. Under Expiry, set an Expires on date (select the date which your access token will expire. Choose a long validity period, so that StackGuardian integration continues to work).
  8. Select the permissions the Access Token needs. (for detailed descriptions of each permission, see Repository-level access token permissions):
    • Projects: Read
    • Repositories: Read

project-create-access-token

  1. Click on Create to generate the new access token.
  2. Copy the generated access token and securely store it. The access token is displayed only once and cannot be retrieved later.

project-copy-access-token

Access token for workspace

Follow these steps to create an Access token for a workspace in Bitbucket:

  1. Login to Bitbucket.
  2. Navigate to target workspace for the access token (this workspace is the only one that the Workspace Access Token can access).
  3. On top bar navigation, Select Settings.
  4. On dropdown menu, select Workspace Settings.
  5. Under Security, select Access Tokens.
  6. Click on Create Access Token.
  7. Provide a Name for the access token.
  8. Under Expiry, set an Expires on date (select the date which your access token will expire. Choose a long validity period, so that StackGuardian integration continues to work).
  9. Select the permissions the Access Token needs (for detailed descriptions of each permission, see Repository-level access token permissions):
    • Account: Read
    • Projects: Read
    • Repositories: Read

workspace-create-access-token

  1. Click on Create to generate the new access token.
  2. Copy the generated access token and securely store it. The access token is displayed only once and cannot be retrieved later.

workspace-create-access-token

Configure the connector in StackGuardian

  1. Enter a Connector name. The connector ID is auto-generated from the name.
  2. Set the Access token you generated in Bitbucket.
  3. Select Create to finalize the connector.
Connect with VCP modal showing Bitbucket selected with API token method and the User name and API token credential fields

Connect with Bitbucket

API token

Create an API token in Bitbucket

To integrate Bitbucket, you first need to create an API token in Bitbucket with limited permissions:

  1. Login to Bitbucket

  2. Navigate to Settings (upper-right corner of the top navigation bar).

  3. Under Personal Settings, go to Atlassian account settings.

  4. Select Security from the top navigation bar.

  5. Under API tokens, click on Create and manage API tokens.

  6. Click on Create API token with scopes.

  7. Provide a Name for the API token.

  8. Set an Expires on date (this is the date when the API Token will expire. Choose a long validity period so that StackGuardian integration continues to work).

  9. Click on Next.

  10. On the Select the app page, under Select API token app, select Bitbucket.

  11. Click on Next.

  12. Under Select bitbucket scopes, Select all of the following scopes (these scopes are required to get read access to the Bitbucket repositories):

    • Account: Read
    • Me: Read
    • Project:bitbucket: Read
    • Pullrequest:bitbucket: Read
    • Repository:bitbucket: Read
    • User:bitbucket: Read
    • Workspace:bitbucket: Read
    Create API token

    Create API token

  13. Click on Next.

  14. Review the details of your API Token and click Create token if it all looks good.

    Review API token

    Review API token

  15. Copy the generated API Token and securely store it. The API Token is displayed only once and cannot be retrieved later.

api-token

Configure the connector in StackGuardian

  1. Enter a Connector name. The connector ID is auto-generated from the name.

  2. Under Credentials, fill in the following:

    FieldDescription
    User nameYour Bitbucket username, for example John Doe
    EmailYour email
    API tokenThe API token you generated in Bitbucket
  3. Select Create to finalize the connector.

Connect with VCP modal showing Bitbucket selected with API token method and the User name and API token credential fields

Connect with Bitbucket