To use the command-line examples in this guide, install and
configure the Google Cloud CLI.
You can either use the same Google Cloud project to create your
private pool and your Cloud Build builds or use different
projects. If your builds are in a different project from your private
pool, set the default project in the gcloud CLI to the project where your
builds originate:
gcloud config set project BUILD_ORIGIN_PROJECT_ID
IAM permissions
To run builds via the gcloud CLI or the Cloud Build API, grant
the WorkerPool User role in the private pool project to the user or service
account that requests the build.
To run automated builds using triggers:
If the project in which you're starting the build is the same as the project
in which your private pool exists, you don't need to grant any
permissions.
If the project in which you're starting the build is different from the
project in which your private pool exists, grant the WorkerPool User
role to the service account you are using with your trigger on the
workerpool project where your builds are created:
Replace the placeholder values in the command above with the following:
PRIVATEPOOL_PROJECT_ID is the ID of the project
with the private pool running the build.
SERVICE_ACCOUNT is the email of the service
account you are using with the trigger executing the build.
Running builds
You can submit builds from the same Google Cloud project where you created the
private pool or from a different Google Cloud project. You can specify
the private pool either in your build config file or direcly in the
gcloud command:
Specifying the private pool in the build config file:
In your Cloud Build config file,
add a pool option and specify the full resource name of the private
pool to run the build:
{"steps":[{"name":"bash","args":["echo","I am running in a private pool!"]}],"options":{"pool":{"name":"projects/PRIVATEPOOL_PROJECT_ID/locations/REGION/workerPools/PRIVATEPOOL_ID"}}}
Replace the placeholder values in the config file above with the following:
PRIVATEPOOL_PROJECT_ID: the Google Cloud project where your
private pool is located.
REGION: the region where you created your private
pool.
PRIVATEPOOL_ID: the unique private pool ID that you specified
when creating the private pool.
Use the build config file created above to run your build via gcloud or API
or using triggers. If your
instance is hosted on-premises, Cloud Build also provides
trigger functionality support for several external
source code management systems such as GitHub Enterprise
or Bitbucket Server.
Specifying the private pool in the gcloud command:
You can specify the private pool in the gcloud command instead of in the
build config file. For example, consider you have the following build config
file:
[[["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 document details how to execute builds within private pools in Google Cloud, requiring prior setup of a private pool.\u003c/p\u003e\n"],["\u003cp\u003eTo run builds through the gcloud CLI or Cloud Build API, the user or service account initiating the build must have the \u003cstrong\u003eWorkerPool User\u003c/strong\u003e role in the private pool project.\u003c/p\u003e\n"],["\u003cp\u003eBuilds can originate from the same or a different Google Cloud project as the private pool, with necessary IAM permissions required if the build is being run in a separate project.\u003c/p\u003e\n"],["\u003cp\u003ePrivate pools can be specified in either the build configuration file using the \u003ccode\u003epool\u003c/code\u003e option, or directly within the \u003ccode\u003egcloud\u003c/code\u003e command using the \u003ccode\u003e--worker-pool\u003c/code\u003e flag.\u003c/p\u003e\n"],["\u003cp\u003eIf automated builds are being used with triggers and the projects differ, the service account of the trigger needs the \u003cstrong\u003eWorkerPool User\u003c/strong\u003e role on the project with the private pool.\u003c/p\u003e\n"]]],[],null,["# Run builds in a private pool\n\nThis document explains how to run builds in private pools. If you're new\nto private pools, read the [Private pools overview](/build/docs/private-pools/private-pools-overview).\n\nBefore you begin\n----------------\n\n- Make sure you've created a private pool using the steps in\n [Creating and managing private pools](/build/docs/private-pools/create-manage-private-pools).\n\n- To use the command-line examples in this guide, install and\n configure the [Google Cloud CLI](https://cloud.google.com/sdk).\n\n | **Note:** If you've installed gcloud CLI previously, make sure you have the latest available version by running `gcloud components update`.\n- You can either use the same Google Cloud project to create your\n private pool and your Cloud Build builds or use different\n projects. If your builds are in a different project from your private\n pool, set the default project in the gcloud CLI to the project where your\n builds originate:\n\n gcloud config set project \u003cvar translate=\"no\"\u003eBUILD_ORIGIN_PROJECT_ID\u003c/var\u003e\n\n### IAM permissions\n\n- To run builds via the gcloud CLI or the Cloud Build API, grant\n the **WorkerPool User** role in the private pool project to the user or service\n account that requests the build.\n\n- To run automated builds using triggers:\n\n - If the project in which you're starting the build is the same as the project in which your private pool exists, you don't need to grant any permissions.\n - If the project in which you're starting the build is different from the\n project in which your private pool exists, grant the **WorkerPool User**\n role to the service account you are using with your trigger on the\n workerpool project where your builds are created:\n\n ### Console\n\n 1. Open the **IAM** page in the Google Cloud console.\n\n [Open the IAM Permissions page](https://console.cloud.google.com/iam-admin/iam)\n 2. In the project selector drop-down menu at the top of the page,\n select the project that contains your private pool.\n\n 3. Click **Grant access**.\n\n 4. Enter the following principal and role settings:\n\n - **Add principals**: Enter email address of the service account that\n you are using with your trigger.\n\n - **Assign roles**: Select the Cloud Build WorkerPool User role.\n\n 5. Click **Save** to save your new IAM permissions.\n\n ### gcloud\n\n **To add the build service account from the trigger\n project to the workerpool project with the cloudbuild.workerPoolUser role**: \n\n gcloud projects add-iam-policy-binding \u003cvar translate=\"no\"\u003ePRIVATEPOOL_PROJECT_ID\u003c/var\u003e \\\n --member=serviceAccount:\u003cvar translate=\"no\"\u003eSERVICE_ACCOUNT\u003c/var\u003e \\\n --role=roles/cloudbuild.workerPoolUser\n\n Replace the placeholder values in the command above with the following:\n - \u003cvar translate=\"no\"\u003ePRIVATEPOOL_PROJECT_ID\u003c/var\u003e is the ID of the project with the private pool running the build.\n - \u003cvar translate=\"no\"\u003eSERVICE_ACCOUNT\u003c/var\u003e is the email of the service account you are using with the trigger executing the build.\n\nRunning builds\n--------------\n\nYou can submit builds from the same Google Cloud project where you created the\nprivate pool or from a different Google Cloud project. You can specify\nthe private pool either in your build config file or direcly in the\n`gcloud` command:\n\n**Specifying the private pool in the build config file:**\n\n1. In your [Cloud Build config file](/build/docs/build-config),\n add a `pool` option and specify the full resource name of the private\n pool to run the build:\n\n ### YAML\n\n steps:\n - name: 'bash'\n args: ['echo', 'I am running in a private pool!']\n options:\n pool:\n name: 'projects/\u003cvar translate=\"no\"\u003ePRIVATEPOOL_PROJECT_ID\u003c/var\u003e/locations/\u003cvar translate=\"no\"\u003eREGION\u003c/var\u003e/workerPools/\u003cvar translate=\"no\"\u003ePRIVATEPOOL_ID\u003c/var\u003e'\n\n ### JSON\n\n {\n \"steps\": [\n {\n \"name\": \"bash\",\n \"args\": [\n \"echo\",\n \"I am running in a private pool!\"\n ]\n }\n ],\n \"options\": {\n \"pool\" : {\n \"name\" : \"projects/\u003cvar translate=\"no\"\u003ePRIVATEPOOL_PROJECT_ID\u003c/var\u003e/locations/\u003cvar translate=\"no\"\u003eREGION\u003c/var\u003e/workerPools/\u003cvar translate=\"no\"\u003ePRIVATEPOOL_ID\u003c/var\u003e\"\n }\n }\n }\n\n Replace the placeholder values in the config file above with the following:\n - \u003cvar translate=\"no\"\u003ePRIVATEPOOL_PROJECT_ID\u003c/var\u003e: the Google Cloud project where your private pool is located.\n - \u003cvar translate=\"no\"\u003eREGION\u003c/var\u003e: the region where you created your private pool.\n - \u003cvar translate=\"no\"\u003ePRIVATEPOOL_ID\u003c/var\u003e: the unique private pool ID that you specified when creating the private pool.\n2. Use the build config file created above to run your build via [`gcloud` or API](/build/docs/running-builds/start-build-manually)\n or using [triggers](/build/docs/running-builds/automate-builds). If your\n instance is hosted on-premises, Cloud Build also provides\n trigger functionality support for several external\n source code management systems such as [GitHub Enterprise](/build/docs/automating-builds/build-repos-from-github-enterprise)\n or [Bitbucket Server](/build/docs/automating-builds/build-repos-from-bitbucket-server).\n\n**Specifying the private pool in the gcloud command:**\n\nYou can specify the private pool in the `gcloud` command instead of in the\nbuild config file. For example, consider you have the following build config\nfile: \n\n### YAML\n\n steps:\n - name: 'bash'\n args: ['echo', 'I am running in a private pool!']\n\n### JSON\n\n {\n \"steps\": [\n {\n \"name\": \"bash\",\n \"args\": [\n \"echo\",\n \"I am running in a private pool!\"\n ]\n }\n ],\n }\n\nThe following command builds using the build config file and specifies the worker\npool in the command: \n\n gcloud builds submit --config=\u003cvar translate=\"no\"\u003eCONFIG_FILE\u003c/var\u003e\n --worker-pool=projects/\u003cvar translate=\"no\"\u003ePRIVATEPOOL_PROJECT_ID\u003c/var\u003e/locations/\u003cvar translate=\"no\"\u003eREGION\u003c/var\u003e/workerPools/\u003cvar translate=\"no\"\u003ePRIVATEPOOL_ID\u003c/var\u003e\n\nReplace the placeholder values in the above commands with the following:\n\n- \u003cvar translate=\"no\"\u003eCONFIG_FILE\u003c/var\u003e: path to your build config file.\n- \u003cvar translate=\"no\"\u003ePRIVATEPOOL_ID\u003c/var\u003e: the unique private pool ID that you specified when creating the private pool.\n- \u003cvar translate=\"no\"\u003ePRIVATEPOOL_PROJECT_ID\u003c/var\u003e: the Google Cloud project where your private pool is located.\n- \u003cvar translate=\"no\"\u003eREGION\u003c/var\u003e: the region where you created your private pool.\n\nWhat's next?\n------------\n\n- Learn how to [create and manage private pools](/build/docs/private-pools/create-manage-private-pools).\n- Learn how to [use VPC Service Controls with private pools](/build/docs/private-pools/using-vpc-service-controls).\n- Learn how to [create and manage build triggers](/build/docs/automating-builds/create-manage-triggers).\n- Learn how to [build repositories from GitHub Enterprise](/build/docs/automating-builds/build-repos-from-github-enterprise).\n- Learn how to [build repositories from Bitbucket Server](/build/docs/automating-builds/build-repos-from-bitbucket-server)."]]