Create and run a build in a private pool

This page explains how to create a Cloud Build private pool connectedto the service producer network, and run a build in the private pool.

The service producer network is the network that hosts the private pool.By default, a private pool is set up to use the service producer network,which provides a build environment with:

  • Configurable machine types
  • Configurable disk sizes
  • Access to resources in the public internet, such as resources in arepository or a registry

To follow step-by-step guidance for this task directly in the Cloud Shell Editor, clickGuide me:

Guide me


Before you begin

  1. Sign in to your Google Cloud account. If you're new to Google Cloud, create an account to evaluate how our products perform in real-world scenarios. New customers also get $300 in free credits to run, test, and deploy workloads.
  2. 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.create permission.Learn how to grant roles.
    Note: If you don't plan to keep the resources that you create in this procedure, create a project instead of selecting an existing project. After you finish these steps, you can delete the project, removing all resources associated with the project.

    Go to project selector

  3. Verify that billing is enabled for your Google Cloud project.

  4. Enable the Cloud Build API.

    Roles required to enable APIs

    To enable APIs, you need the Service Usage Admin IAM role (roles/serviceusage.serviceUsageAdmin), which contains theserviceusage.services.enable permission.Learn how to grant roles.

    Enable the API

  5. Install the Google Cloud CLI.

  6. If you're using an external identity provider (IdP), you must first sign in to the gcloud CLI with your federated identity.

  7. Toinitialize the gcloud CLI, run the following command:

    gcloudinit
  8. 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.create permission.Learn how to grant roles.
    Note: If you don't plan to keep the resources that you create in this procedure, create a project instead of selecting an existing project. After you finish these steps, you can delete the project, removing all resources associated with the project.

    Go to project selector

  9. Verify that billing is enabled for your Google Cloud project.

  10. Enable the Cloud Build API.

    Roles required to enable APIs

    To enable APIs, you need the Service Usage Admin IAM role (roles/serviceusage.serviceUsageAdmin), which contains theserviceusage.services.enable permission.Learn how to grant roles.

    Enable the API

  11. Install the Google Cloud CLI.

  12. If you're using an external identity provider (IdP), you must first sign in to the gcloud CLI with your federated identity.

  13. Toinitialize the gcloud CLI, run the following command:

    gcloudinit
  14. If you've already installed Google Cloud CLI previously, make sure you have thelatest available version by runninggcloud components update.

Create a private pool

  1. In the Google Cloud console, open theCloud Build Worker pool tab:

    Open the Cloud Build worker pool tab

  2. ClickCreate.

  3. In theCreate private pool panel, enter the following settings:

    1. In theName field, entermy-first-privatepool.

    2. In theRegion field, selectus-central1.

    3. In theMachine type field, selecte2-standard-2.

    4. In theAvailable disk size field, enter800.

    5. Leave theNetwork project number field blank.

    6. Leave theNetwork field blank.

    7. Make sureAssign external IPs is selected.

ClickCreate to create the private pool.

Allow a short time for the private pool to be created. After the private poolis created, it is listed on theWorker pool tab.

Screenshot of the private pool page

Run a build in a private pool

  1. Open a terminal window.

  2. Create a new directory namedquickstart-private-pool and navigate into it:

    mkdir quickstart-private-poolcd quickstart-private-pool
  3. Create a file namedcloudbuild.yaml with the following contents:

    steps:- name: "bash"  script: echo "I am running in a private pool!"options:  pool:    name: "projects/$PROJECT_ID/locations/us-central1/workerPools/my-first-privatepool"
  4. Start the build using the build config file:

    gcloudbuildssubmit

When the build is complete, you'll see an output similar to the following:

I am running in a private pool!PUSHDONE------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ID                                    CREATE_TIME                DURATION  SOURCE                                                                                       IMAGES  STATUS5df45735-6414-40b7-9e10-e6d2023c8cea  2020-08-31T13:16:18+00:00  10S       gs://private-pool-test_cloudbuild/source/1598879777.206444-    58901ecbd14e431f8cdacc85d5dd0fc3.tgz-       SUCCESS

View build details

  1. Open theBuild history page in the Google Cloud console.

    Open the Cloud Build page

  2. In theRegion drop-down box, selectus-central1.

    You will see the build that you ran in the private pool.
  3. Click on the build to view the build details, such as build summary and artifacts.

Clean up

To avoid incurring charges to your Google Cloud account for the resources used on this page, follow these steps.

  1. Open theWorker pool page in the Google Cloud console:

    Open the Cloud Build private pool page

  2. In the row with your private pool, click the trash icon.

  3. In theDelete private pool? pop-up box, clickDelete.

The private pool that you created as part of this quickstart is now deleted.You might need to refresh your screen to delete the private pool from theWorker pool page.

What's next

Except as otherwise noted, the content of this page is licensed under theCreative Commons Attribution 4.0 License, and code samples are licensed under theApache 2.0 License. For details, see theGoogle Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.

Last updated 2026-02-18 UTC.