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:
- In StackGuardian, navigate to Organization Settings → Connectors → Version control providers.
- Select + Connect with VCS provider.
- In the Connect with VCP modal, select Bitbucket as the version control provider.
- Choose an authentication method:
- Access token (recommended)
- API token

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:
- Login to Bitbucket.
- Navigate to target repository for the access token (this repository is the only one that the access token can access).
- On the sidebar, select Repository Settings.
- Under Security, select Access Tokens.
- Click on Create Access Token.
- Provide a Name for the access token.
- 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).
- Select the permissions the access token needs (for detailed descriptions of each permission, see Repository-level access token permissions):
- Repositories:
Read
- Repositories:

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

Access token for project
Follow these steps to create an access token for a project in Bitbucket:
- Login to Bitbucket.
- Navigate to target project for the access token (this project is the only one that the access token can access).
- On the sidebar, select Project Settings.
- Under Security, select Access Tokens.
- Click on Create Access Token.
- Provide a Name for the access token.
- 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).
- Select the permissions the Access Token needs. (for detailed descriptions of each permission, see Repository-level access token permissions):
- Projects:
Read - Repositories:
Read
- Projects:

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

Access token for workspace
Follow these steps to create an Access token for a workspace in Bitbucket:
- Login to Bitbucket.
- Navigate to target workspace for the access token (this workspace is the only one that the Workspace Access Token can access).
- On top bar navigation, Select Settings.
- On dropdown menu, select Workspace Settings.
- Under Security, select Access Tokens.
- Click on Create Access Token.
- Provide a Name for the access token.
- 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).
- 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
- Account:

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

Configure the connector in StackGuardian
- Enter a Connector name. The connector ID is auto-generated from the name.
- Set the Access token you generated in Bitbucket.
- Select Create to finalize the connector.

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:
-
Login to Bitbucket
-
Navigate to Settings (upper-right corner of the top navigation bar).
-
Under Personal Settings, go to Atlassian account settings.
-
Select Security from the top navigation bar.
-
Under API tokens, click on Create and manage API tokens.
-
Click on Create API token with scopes.
-
Provide a Name for the API token.
-
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).
-
Click on Next.
-
On the Select the app page, under Select API token app, select Bitbucket.
-
Click on Next.
-
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
- Account:
-
Click on Next.
-
Review the details of your API Token and click Create token if it all looks good.

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

Configure the connector in StackGuardian
-
Enter a Connector name. The connector ID is auto-generated from the name.
-
Under Credentials, fill in the following:
Field Description User name Your Bitbucket username, for example John DoeEmail Your email API token The API token you generated in Bitbucket -
Select Create to finalize the connector.

Connect with Bitbucket