Mantenha tudo organizado com as coleções
Salve e categorize o conteúdo com base nas suas preferências.
Neste documento, explicamos como executar builds em pools particulares. Se você estiver começando a usar
os pools particulares, leia a Visão geral dos pools particulares.
Para usar os exemplos de linha de comando neste guia, instale e
configure a Google Cloud CLI.
É possível usar o mesmo projeto Google Cloud para criar o
pool particular e os builds do Cloud Build ou usar projetos
diferentes. Se os builds estiverem em um projeto diferente do seu pool particular, defina o projeto padrão na CLI gcloud como o projeto em que os builds são originados:
gcloud config set project BUILD_ORIGIN_PROJECT_ID
Permissões do IAM
Para executar builds pela CLI gcloud ou pela API Cloud Build, conceda
o papel de usuário do WorkerPool no projeto do pool particular à conta de usuário ou de serviço
que solicita o build.
Para executar versões automatizadas usando acionadores:
Se o projeto em que você está iniciando a versão for o mesmo em que o pool privado se encontra, não será necessário conceder
permissões.
Se o projeto em que você está iniciando a compilação for diferente do projeto em que o pool privado existe, conceda o papel Usuário do pool de workers à conta de serviço que você está usando com o acionador no projeto do pool de workers em que os builds são criados:
Substitua os valores de marcador no comando acima pelo seguinte:
PRIVATEPOOL_PROJECT_ID é o ID do projeto
com o pool particular executando a versão.
SERVICE_ACCOUNT é o e-mail da conta de serviço que você está usando com o gatilho que executa o build.
Como executar versões
É possível enviar builds do mesmo projeto Google Cloud em que você criou o
pool particular ou de um projeto Google Cloud diferente. É possível especificar
o pool particular no arquivo de configuração do build ou diretamente no
comando gcloud:
Como especificar o pool particular no arquivo de configuração do 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"}}}
Substitua os valores de marcador no arquivo de configuração acima pelo seguinte:
PRIVATEPOOL_PROJECT_ID: o projeto Google Cloud em que o
pool particular está localizado.
REGION: a região em que você criou o pool
particular.
PRIVATEPOOL_ID: o ID do pool particular exclusivo que você especificou ao criar o pool particular.
Use o arquivo de configuração do build criado acima para executar seu build via gcloud ou API
ou usando gatilhos. Se a
instância estiver hospedada no local, o Cloud Build também oferecerá
suporte à funcionalidade do gatilho para vários sistemas de gerenciamento
de código-fonte externos, como GitHub Enterprise ou Bitbucket Server.
Como especificar o pool particular no comando gcloud:
É possível especificar o pool particular no comando gcloud em vez de no
arquivo de configuração do build. Por exemplo, considere que você tenha o seguinte arquivo de configuração
do build:
[[["Fácil de entender","easyToUnderstand","thumb-up"],["Meu problema foi resolvido","solvedMyProblem","thumb-up"],["Outro","otherUp","thumb-up"]],[["Difícil de entender","hardToUnderstand","thumb-down"],["Informações incorretas ou exemplo de código","incorrectInformationOrSampleCode","thumb-down"],["Não contém as informações/amostras de que eu preciso","missingTheInformationSamplesINeed","thumb-down"],["Problema na tradução","translationIssue","thumb-down"],["Outro","otherDown","thumb-down"]],["Última atualização 2025-08-18 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)."]]