Connect to a Bitbucket Data Center repository

This page explains how to connect to a Bitbucket Data Center repository to Cloud Build.

Before you begin

  • Enable the Cloud Build and Secret Manager APIs.

    Enable the APIs

Connect to a Bitbucket Data Center repository

Console

  1. Open the Repositories page in the Google Cloud console.

    Open the Repositories page

    You will see the Repositories page.

  2. At the top of the page, select the 2nd gen tab.

  3. In the project selector, select your Google Cloud project.

  4. Click Link repository to link repositories from your connection.

    You will see the Link repositories panel.

  5. In the Link repositories panel, enter the following information:

    1. Connection: Select a connection from the drop-down menu.

    2. Repository: Select one or more repositories to link to your connection.

    3. Repository Resource Name: Use these fields to create resource names for the repositories that are linked.

      1. Generated: Select this option for Cloud Build to automatically generate repository resource names on your behalf for selected repositories.
      2. Manual: Select this option to manually specify repository resource names.

        If you select Manual, you can modify the names for your selected repositories in the Repository names section.

  6. Click Link to link your repository to your connection.

gcloud

To add a Bitbucket Data Center repository to your connection, run the following command:

gcloud builds repositories create REPO_NAME \
    --remote-uri=REPO_URI \
    --connection=CONNECTION_NAME --region=REGION

Where:

  • REPO_NAME is the name of your repository.
  • REPO_URI is the link to your Bitbucket Data Center repository. For example, https://bbdc-host.com/scm/myproject/myrepo.git.
  • CONNECTION_NAME is the name of your connection.
  • REGION is the region for your connection.

Terraform

To add a Bitbucket Data Center repository to your connection, add the following code snippet to your Terraform configuration:

    resource "google_cloudbuildv2_repository" "my-repository" {
        project = "PROJECT_ID"
        name = "REPO_NAME"
        location = "REGION"
        parent_connection = google_cloudbuildv2_connection.RESOURCE_NAME.name
        remote_uri = "REPO_URI"
    }

Where:

  • PROJECT_ID is your Google Cloud project ID.
  • REPO_NAME is the name of your repository.
  • REGION is the region for your connection.
  • RESOURCE_NAME is the name of the google_cloudbuildv2_connection resource. For example, my-connection from the Terraform example in Connect to a Bitbucket Data Center host.
  • REPO_URI is the link to your Bitbucket Data Center repository. For example, https://bbdc-host.com/scm/myproject/myrepo.git.

What's next