Cloud Build Study Notes
Cloud Build is Google Cloud's serverless continuous integration and continuous delivery platform that executes builds on Google infrastructure in response to source changes or manual invocation. A build is a series of steps, each running in a container, defined in a cloudbuild.yaml file or a Dockerfile.
Key facts
- A build config lists steps in order; each step names a builder container image and its arguments, and steps can pass files to later steps through the shared workspace volume.
- Cloud Build can be triggered manually with gcloud, from source repositories on push or pull request events, by Pub/Sub messages, and by webhook events from external systems.
- Substitutions let you parameterize a build with variables such as branch name or a custom value, and built-in substitutions provide values like the project ID, commit SHA, and trigger name.
- By default builds run on shared worker pools managed by Google; private pools run workers inside your VPC network so builds can reach private resources without exposing them publicly.
- A build can specify a timeout, machine type, disk size, and logging destination, and its full history, logs, and step timings are retained in the console for troubleshooting.
- The Cloud Build service account executes the build, so it must be granted IAM roles to push images, deploy services, or write artifacts, following least privilege.
- Cloud Build supports building a Dockerfile directly without a config file, and also supports multi-step pipelines that test, scan, build, and deploy in sequence.
- Build artifacts and container images are typically stored in Artifact Registry, Cloud Storage, or both, as declared in the images and artifacts sections of the build config.
What the exam expects you to know
- Reading a simple cloudbuild.yaml to identify step order, builder images, and where the finished image is pushed.
- Choosing a trigger type, especially a repository push trigger, to automate builds and tests when code changes.
- Granting the Cloud Build service account the minimum roles needed to push to Artifact Registry or deploy to Cloud Run or GKE.
- Using private pools when a build must access resources that exist only inside a VPC network, such as a private database or internal repository.
- Applying substitutions so one build configuration works across branches, environments, or projects without duplication.
- Diagnosing a failed build from step logs and exit status rather than guessing, and knowing builds stop at the first failed step by default.
Cloud Build vs Cloud Deploy: when to use which
Choose Cloud Build when the job is to compile code, run tests, and produce artifacts such as container images or packages; it is the build and CI side of the pipeline. Choose Cloud Deploy when the job is to deliver an already-built artifact to target runtimes such as GKE or Cloud Run with controlled promotions, approvals, and rollback. Many pipelines use both in sequence: Cloud Build creates and tests the image, stores it in Artifact Registry, and then hands delivery to Cloud Deploy for staged, auditable releases across environments. See also the Cloud Deploy notes.
Useful gcloud commands
gcloud builds submit --tag gcr.io/my-project/my-image
gcloud builds list
gcloud builds log BUILD_ID
gcloud builds triggers listCommon exam traps
- Assuming the build runs as your personal account: builds execute as the Cloud Build service account, so permission errors usually mean that account lacks a role, not that you do.
- Expecting steps to run in parallel by default: steps run sequentially unless you use waitFor to define dependencies and allow independent steps to run concurrently.
- Forgetting that a Dockerfile-only build cannot run tests or extra steps: anything beyond a simple image build needs a build configuration file with explicit steps.
- Storing secrets directly in cloudbuild.yaml: reference Secret Manager from the build instead of committing credentials to source control.
Frequently asked questions
What is a build step in Cloud Build?
A step is one containerized action in a build, such as compiling code, running unit tests, or building a Docker image. Each step specifies a builder image and its entrypoint arguments, runs in the shared workspace, and must exit successfully before dependent steps continue. The sequence of steps defines your whole pipeline.
How do triggers automate builds?
A trigger watches a source, such as a repository push, a pull request, a Pub/Sub message, or a webhook, and starts a build automatically when the event matches its filter. Triggers can include or exclude branches and file paths, pass substitutions, and point at the build configuration stored in the repository or defined inline.
When do I need a private worker pool?
Use a private pool when build steps must reach resources inside your VPC, such as a private artifact server, an on-premises system reached through VPN, or a database with no public address. Private pool workers run in a network peered to your VPC, while the default public pool cannot reach private-only resources.
Study aid disclaimer: Cloud Cert Notes is an independent educational study aid. It is not affiliated with, endorsed by, or sponsored by Google, Microsoft, Amazon, Oracle, or Alibaba. Google Cloud, Associate Cloud Engineer, and Cloud Digital Leader are trademarks of Google LLC; all other certification names and product names are trademarks of their respective owners. Always confirm service details against the official provider documentation before sitting an exam.