These instructions are for application developers, platform administrators, and security managers who want to use Bitbucket Cloud source code repositories with Google. Specifically, you can use Bitbucket Cloud repositories with Gemini Code Assist.
To learn more about Developer Connect, see Developer Connect overview.
Before you begin
-
Sign in to your Google Account.
If you don't already have one, sign up for a new account.
-
In the Google Cloud console, on the project selector page, select or create a Google Cloud project.
Roles required to select or create a project
- Select a project: Selecting a project doesn't require a specific IAM role—you can select any project that you've been granted a role on.
-
Create a project: To create a project, you need the Project Creator role
(
roles/resourcemanager.projectCreator), which contains theresourcemanager.projects.createpermission. Learn how to grant roles.
-
Verify that billing is enabled for your Google Cloud project.
Enable the Developer Connect API.
Roles required to enable APIs
To enable APIs, you need the
serviceusage.services.enablepermission. If you created the project, then you likely already have this permission through the Owner role (roles/owner). Otherwise, you can get this permission through the Service Usage Admin role (roles/serviceusage.serviceUsageAdmin). Learn how to grant roles.-
In the Google Cloud console, on the project selector page, select or create a Google Cloud project.
Roles required to select or create a project
- Select a project: Selecting a project doesn't require a specific IAM role—you can select any project that you've been granted a role on.
-
Create a project: To create a project, you need the Project Creator role
(
roles/resourcemanager.projectCreator), which contains theresourcemanager.projects.createpermission. Learn how to grant roles.
-
Verify that billing is enabled for your Google Cloud project.
Enable the Developer Connect API.
Roles required to enable APIs
To enable APIs, you need the
serviceusage.services.enablepermission. If you created the project, then you likely already have this permission through the Owner role (roles/owner). Otherwise, you can get this permission through the Service Usage Admin role (roles/serviceusage.serviceUsageAdmin). Learn how to grant roles.-
Ensure that you have access to an account on Bitbucket Cloud.
To help keep your team's work secure, we recommend that you complete the tasks in this guide using a bot account or an account shared by your team, not a personal account.
- Ensure that you own a Bitbucket Cloud repository, or have admin-level permissions on a shared repository.
- Optional: Create a customer-managed encryption key (CMEK) for encrypting the authentication secrets that Developer Connect creates.
- Optional: To use the command-line instructions in this guide, complete the
following steps:
- Install the Google Cloud CLI. If
you've installed gcloud CLI previously, make sure you have
the latest available version by running
gcloud components update. - Create a Developer Connect service account
by running the following command, where PROJECT_ID is your Google Cloud project ID:
gcloud beta services identity create \ --service=developerconnect.googleapis.com \ --project=PROJECT_ID
- Install the Google Cloud CLI. If
you've installed gcloud CLI previously, make sure you have
the latest available version by running
Enabling Developer Connect also enables the Secret Manager API.
Required roles
To get the permissions that you need to create connections and links, ask your administrator to grant you the following IAM roles:
-
If you aren't the project owner:
Developer Connect Admin (
roles/developerconnect.admin) on your user account. -
If you plan to use a CMEK to encrypt the secrets that Developer Connect creates:
Cloud KMS CryptoKey Encrypter/Decrypter (
roles/cloudkms.cryptoKeyEncrypterDecrypter) on the Secret Manager Service Account. -
If you plan to use the gcloud CLI to complete the steps in this guide:
Secret Manager Admin role (
roles/secretmanager.admin) on the Developer Connect Service Account. -
If you plan to use the Google Cloud console to complete the steps in this guide:
Project IAM Admin (
roles/resourcemanager.projectIamAdmin) on your user account.
For more information about granting roles, see Manage access to projects, folders, and organizations.
You might also be able to get the required permissions through custom roles or other predefined roles.
Create access tokens
Create personal access tokens in Bitbucket Cloud by completing the following steps:
Complete the following steps to create two access tokens in Bitbucket Cloud. These can be Repository Access Tokens, Project Access Tokens, or Workspace Access Tokens.
Choose the instructions for the type of access token you will use:
Create the first token with the following scopes:
- Repositories: read.
- Pull Requests: read.
- Webhooks: read and write.
In Developer Connect, this is called your Authorizer access token.
Create the second token with the following scope:
- Repositories: read.
In Developer Connect, this is called your Read access token.
You are responsible for managing token lifetimes in Bitbucket Cloud. Bitbucket Cloud tokens have no expiry and will remain valid until you revoke them.
Some types of Bitbucket tokens are premium features exclusively available in paid plans. For more information, see Bitbucket Cloud tokens.
Copy the access tokens for use in the following procedures.
Create a connection
This section describes how to create a connection between Developer Connect and Bitbucket Cloud. If you're using the Google Cloud console, then you can also start adding links to repositories as you finish setting up your connection.
To create a new Bitbucket Cloud connection, select one of the following options:
Console
Initiate a connection by completing the following steps:
In the Google Cloud console, open Developer Connect.
Developer Connect displays the Git repositories page.
- If you see a list of source code management providers: Start configuring your first connection by selecting a source code management provider. Click Connect on the Bitbucket Cloud card.
If you see a table listing existing connections: Set the source code management provider by clicking Create connection > Bitbucket Cloud.
The Create Connection page opens.
For Region, choose a region for your connection resources.
- For Name, enter a name for your new connection.
For Workspace, enter your Bitbucket Cloud workspace ID.
In the Access Tokens section, enter your Bitbucket Cloud access tokens:
- Authorizer access token: Enter your authorizer access token.
- Read access token: Enter your read access token.
Click Show more to see optional configuration settings.
Optional: In the Encryption section, select a CMEK key to encrypt Secret Manager secrets that Developer Connect creates.
Optional: By default, Developer Connect can act as a proxy for Git calls to Bitbucket Cloud. To disable this option, clear the Enable Developer Connect proxy checkbox.
To finish configuring your connection, click the Continue button.
Developer Connect creates your connection. This process can take a few seconds.
Once the connection is created, the Link repositories page appears.
Complete the following steps to link repositories to your connection:
In the list of available repositories, select the repositories you want to use.
Click OK.
Click Link.