RESOURCE_NAME is the name of the
google_cloudbuildv2_connection resource. For example, my-connection from
the Terraform example in Connect to a Bitbucket Cloud host.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Hard to understand","hardToUnderstand","thumb-down"],["Incorrect information or sample code","incorrectInformationOrSampleCode","thumb-down"],["Missing the information/samples I need","missingTheInformationSamplesINeed","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2025-08-07 UTC."],[[["\u003cp\u003eThis guide outlines the process of connecting a Bitbucket Cloud repository to Cloud Build.\u003c/p\u003e\n"],["\u003cp\u003eBefore initiating the connection, it is necessary to enable the Cloud Build API and set up a connection to a Bitbucket Cloud host.\u003c/p\u003e\n"],["\u003cp\u003eConnections can be established through the Google Cloud console, which offers options for automatically generating repository resource names or specifying them manually.\u003c/p\u003e\n"],["\u003cp\u003eThe gcloud CLI provides an alternative method for connecting to a Bitbucket Cloud repository, requiring specification of repository, workspace, connection, region, and project details.\u003c/p\u003e\n"],["\u003cp\u003eTerraform configuration can also be employed to link a Bitbucket Cloud repository, which mandates detailing the project ID, workspace ID, repository name, region, and resource name.\u003c/p\u003e\n"]]],[],null,["# Connect to a Bitbucket Cloud repository\n\nThis page explains how to connect a [Bitbucket Cloud](https://support.atlassian.com/bitbucket-cloud/docs/get-started-with-bitbucket-cloud/) repository\nto Cloud Build.\n\nBefore you begin\n----------------\n\n-\n\n\n Enable the Cloud Build API.\n\n\n [Enable the API](https://console.cloud.google.com/flows/enableapi?apiid=cloudbuild.googleapis.com&redirect=https://cloud.google.com/build/docs/automating-builds/bitbucket/connect-repo-from-bitbucket-cloud)\n\n\u003c!-- --\u003e\n\n- Follow instructions in [Connect to a Bitbucket Cloud host](/build/docs/automating-builds/bitbucket/connect-host-bitbucket-cloud).\n\nConnect to Bitbucket Cloud repositories\n---------------------------------------\n\n### Console\n\nConnect Cloud Build to your Bitbucket Cloud repository by\ndoing the following steps:\n\n1. Open the **Repositories** page in the Google Cloud console.\n\n [Open the Repositories page](https://console.cloud.google.com/cloud-build/repositories)\n\n You will see the **Repositories** page.\n2. In the project selector, select your Google Cloud project.\n\n3. Select the **2nd gen** tab.\n\n4. Click **Link repository** to connect a new host to Cloud Build.\n\n You will see the **Link repositories** side panel.\n5. **Connection**: Select a host connection from the drop-down menu.\n\n6. **Repository**: Select a repository from the drop-down menu.\n\n7. **Repository Resource Name**: This step creates resource names for the\n linked repositories.\n\n - **Generated**: Select this option for Cloud Build to automatically generate repository resource names on your behalf for selected repositories.\n - **Manual**: Select this option to manually specify repository resource names.\n\n If you select **Manual** , then you can modify the names for your\n selected repositories in the **Repository names** section.\n8. Click **Link**.\n\n### gcloud\n\nConnect to your Bitbucket Cloud repository: \n\n gcloud builds repositories create \u003cvar translate=\"no\"\u003eREPO_NAME\u003c/var\u003e \\\n --remote-uri=https://bitbucket.org/\u003cvar translate=\"no\"\u003eWORKSPACE\u003c/var\u003e/\u003cvar translate=\"no\"\u003eREPOSITORY\u003c/var\u003e.git \\\n --connection=\u003cvar translate=\"no\"\u003eCONNECTION_NAME\u003c/var\u003e --region=\u003cvar translate=\"no\"\u003eREGION\u003c/var\u003e --project=\u003cvar translate=\"no\"\u003ePROJECT_ID\u003c/var\u003e\n\nWhere:\n\n- \u003cvar translate=\"no\"\u003eREPO_NAME\u003c/var\u003e is the name of your repository.\n- \u003cvar translate=\"no\"\u003eWORKSPACE\u003c/var\u003e is the workspace ID for your repository.\n- \u003cvar translate=\"no\"\u003eREPOSITORY\u003c/var\u003e is the name of the repository.\n- \u003cvar translate=\"no\"\u003eREGION\u003c/var\u003e is the [region](/build/docs/locations) for your connection.\n- \u003cvar translate=\"no\"\u003eCONNECTION_NAME\u003c/var\u003e is the name given to the Bitbucket Cloud host connection created in Cloud Build from [Connect to a Bitbucket Cloud host](/build/docs/automating-builds/bitbucket/connect-host-bitbucket-cloud#connect-host).\n- \u003cvar translate=\"no\"\u003ePROJECT_ID\u003c/var\u003e is your Google Cloud [project ID](/resource-manager/docs/creating-managing-projects#get_an_existing_project).\n\n### Terraform\n\nTo add a Bitbucket Cloud repository to your connection, add the following\ncode snippet to your Terraform configuration: \n\n resource \"google_cloudbuildv2_repository\" \"my-repository\" {\n project = \"\u003cvar translate=\"no\"\u003ePROJECT_ID\u003c/var\u003e\"\n name = \"\u003cvar translate=\"no\"\u003eREPO_NAME\u003c/var\u003e\"\n location = \"\u003cvar translate=\"no\"\u003eREGION\u003c/var\u003e\"\n parent_connection = google_cloudbuildv2_connection.\u003cvar translate=\"no\"\u003eRESOURCE_NAME\u003c/var\u003e.name\n remote_uri = \"https://bitbucket.org/\u003cvar translate=\"no\"\u003eWORKSPACE_ID\u003c/var\u003e/\u003cvar translate=\"no\"\u003eREPO_NAME\u003c/var\u003e.git\"\n }\n\nWhere:\n\n- \u003cvar translate=\"no\"\u003ePROJECT_ID\u003c/var\u003e is your Google Cloud [project ID](/resource-manager/docs/creating-managing-projects#get_an_existing_project).\n- \u003cvar translate=\"no\"\u003eWORKSPACE_ID\u003c/var\u003e is the workspace ID for your repository.\n- \u003cvar translate=\"no\"\u003eREPO_NAME\u003c/var\u003e is the name of your repository.\n- \u003cvar translate=\"no\"\u003eREGION\u003c/var\u003e is the [region](/build/docs/locations) for your connection.\n- \u003cvar translate=\"no\"\u003eRESOURCE_NAME\u003c/var\u003e is the name of the `google_cloudbuildv2_connection` resource. For example, `my-connection` from the Terraform example in [Connect to a Bitbucket Cloud host](/build/docs/automating-builds/bitbucket/connect-host-bitbucket-cloud#terraform).\n\nWhat's next\n-----------\n\n- Learn how to [build repositories from a Bitbucket Cloud](/build/docs/automating-builds/bitbucket/build-repos-from-bitbucket-cloud).\n- Learn how to [view build results](/build/docs/view-build-results).\n- Learn how to [perform blue/green deployments on Compute Engine](/build/docs/deploying-builds/deploy-compute-engine)."]]