Professional Cloud DevOps Engineer · Domain 2: Building, implementing, and maintaining CI/CD pipelines, including continuous testing, for application, infrastructure, and ML workloads · 30% of the exam
Task 2.1: Building pipelines.
CI/CD for applications and infrastructure, artifacts in Artifact Registry, deploying to GKE in hybrid and multicloud environments, pipeline triggers and approval flows.
Study it
Building pipelines: triggers, artifacts, GKE targets and approval flows
Lesson coming
Rollouts on Kubernetes: rolling updates, readiness and rollback
Try each one before opening the answer. Every option is explained, with the Google Cloud documentation page that proves it.
Question 1 · choose 1
A team's release build in Cloud Build signs and publishes artifacts. It must run only when someone marks a commit as a release, such as v2.4.0 or v2.4.1, and never for ordinary commits to main or to feature branches. How should the team configure the build trigger?
AThe Push new tag event, with a regular expression that matches only semantic version names
BThe Push to a branch event on main, with included files set to the release version names
CThe Push to a branch event, with a branch regular expression that matches names starting with v
DThe Pull request event on main, with a regular expression that matches the version in the title
Show the answer and why
AThe Push new tag event, with a regular expression that matches only semantic version names
Correct
A Push new tag trigger starts a build for commits that carry a matching tag, and the tag value is matched with an RE2 regular expression.
BThe Push to a branch event on main, with included files set to the release version names
Incorrect
Included files filter on changed file paths, so the build would still start from ordinary commits to main that touch those paths.
CThe Push to a branch event, with a branch regular expression that matches names starting with v
Incorrect
A branch expression matches branch names; tags are a separate event, so a release tag never starts this trigger.
DThe Pull request event on main, with a regular expression that matches the version in the title
Incorrect
Pull request triggers build commits of pull requests against the base branch; they are not started by release tags.
Cloud Build triggers start on a repository event: a push to a branch, a push of a new tag, or a pull request. Release builds keyed on version tags use the Push new tag event with an RE2 expression for the tag names, so ordinary branch commits never start them.
A Cloud Build trigger runs terraform apply for the production project on every push to main. The change board now wants each of these builds to wait until a release manager says yes in Google Cloud, and the developers who can merge to main must not be able to let a build through on their own. What should the DevOps engineer configure?
AComment control set to Required on the trigger, so a build waits for a /gcbrun comment from a collaborator
BApproval required on the trigger, with the Cloud Build Approver role granted only to the release managers
CThe trigger disabled, with Cloud Build Editor granted to release managers so they start each apply by hand
DApproval required on the trigger, with the Cloud Build Approver role granted to the developers' group
Show the answer and why
AComment control set to Required on the trigger, so a build waits for a /gcbrun comment from a collaborator
Incorrect
Comment control applies to pull request triggers and is satisfied by any repository owner or collaborator, not by a release manager in Google Cloud.
BApproval required on the trigger, with the Cloud Build Approver role granted only to the release managers
Correct
A trigger that requires approval marks each build as pending, and only principals with the Cloud Build Approver role can approve or reject it.
CThe trigger disabled, with Cloud Build Editor granted to release managers so they start each apply by hand
Incorrect
Cloud Build Editor also lets its holders change triggers, including whether they require approval, and manual runs leave no approve or reject decision on a pending build.
DApproval required on the trigger, with the Cloud Build Approver role granted to the developers' group
Incorrect
The gate exists, but the developers who merge could then approve their own builds.
Cloud Build approvals gate a trigger's builds: each build stays pending until someone with the Cloud Build Approver role approves it (or rejects it, and then it never starts). Granting that role only to release managers separates merging from releasing.
Python builds in Cloud Build install internal packages from an Artifact Registry standard repository and public packages from PyPI through an Artifact Registry remote repository. A security review warns that if someone publishes a package on PyPI with the same name as an internal one, pip could install the public package instead. Which TWO steps protect the builds? (Choose TWO.)
ACreate a virtual repository whose upstreams are the standard and the remote repository, with the standard repository given the higher priority value
BCreate a virtual repository over both repositories, with the standard repository given priority 1 and the remote repository priority 10
CKeep both repositories and list them for pip as an index URL and an extra index URL in the build steps
DAdd a cleanup policy to the remote repository that deletes cached package versions older than 30 days
EPoint pip in every build at the virtual repository only, with no other package index configured
Show the answer and why
ACreate a virtual repository whose upstreams are the standard and the remote repository, with the standard repository given the higher priority value
Correct
A virtual repository serves both upstreams through one endpoint and, when a package exists in both, picks the upstream with the higher priority value.
BCreate a virtual repository over both repositories, with the standard repository given priority 1 and the remote repository priority 10
Incorrect
Priority is a weight, not a ranking: the higher value wins, so this order would prefer the public package.
CKeep both repositories and list them for pip as an index URL and an extra index URL in the build steps
Incorrect
pip gives no control over the search order between mixed private and public indexes, which is the dependency confusion risk itself.
DAdd a cleanup policy to the remote repository that deletes cached package versions older than 30 days
Incorrect
Cleanup policies manage storage by deleting versions; they do not decide which repository a package is resolved from.
EPoint pip in every build at the virtual repository only, with no other package index configured
Correct
When clients read only from the virtual repository, the client logic takes no part in choosing the repository.
To mitigate dependency confusion, Artifact Registry recommends a remote repository as the proxy for the public index, a standard repository for private packages, and a virtual repository that prioritizes the standard repository when a package exists in both; clients then read from the virtual repository only. Upstream priority is a weight: the higher number wins.
An open source project on GitHub runs pull request builds in Cloud Build that can reach a test project. Pull requests opened by the project's own maintainers should build automatically, as they do today. Pull requests from outside contributors must not build until a maintainer has read the change and asked for a build on the pull request itself. Which trigger setting fits?
AComment control set to Required except for owners and collaborators
BComment control set to Required for every pull request
CApproval required on the trigger, with Cloud Build Approver for maintainers
DComment control set to Not required, with ignored files for workflows
Show the answer and why
AComment control set to Required except for owners and collaborators
Correct
Builds start on their own for owners and collaborators, while an outside contributor's pull request builds only after an owner or collaborator comments /gcbrun on it.
BComment control set to Required for every pull request
Incorrect
Every pull request, the maintainers' own included, then waits for a /gcbrun comment, so maintainers lose their automatic builds.
CApproval required on the trigger, with Cloud Build Approver for maintainers
Incorrect
Every build of the trigger, the maintainers' included, waits for an approval in Google Cloud rather than for a request on the pull request.
DComment control set to Not required, with ignored files for workflows
Incorrect
With Not required, any contributor's pull request builds at once, and ignored files can be set only on push to branch or push tag triggers.
For GitHub pull request triggers, comment control decides who can start a build. Required except for owners and collaborators keeps automatic builds for trusted members and holds outside contributors' pull requests until an owner or collaborator comments /gcbrun. Required holds everyone; Not required holds no one; trigger approvals hold every build in Google Cloud.
A change-management tool outside Google Cloud must start a Cloud Build build each time a change ticket is approved. The tool can only send an HTTP POST request to a URL, has no Google credentials and is not a source code repository. The build clones the code itself with an inline build configuration. Which kind of Cloud Build trigger fits?
AA Pub/Sub trigger subscribed to a topic that the tool publishes a message to after each approval
BA webhook trigger, whose URL holds an API key and a secret that Cloud Build keeps in Secret Manager
CA manual trigger that the release manager runs from the console each time the tool reports an approval
DA repository trigger on push events, with the tool's approvals recorded as commits to a branch
Show the answer and why
AA Pub/Sub trigger subscribed to a topic that the tool publishes a message to after each approval
Incorrect
Publishing to Pub/Sub needs an authenticated Google Cloud identity, which the tool does not have.
BA webhook trigger, whose URL holds an API key and a secret that Cloud Build keeps in Secret Manager
Correct
Webhook triggers accept authenticated events sent with POST to a custom URL, connect external systems directly, and can run an inline build configuration without a source.
CA manual trigger that the release manager runs from the console each time the tool reports an approval
Incorrect
A manual trigger needs a person to start each build, so approvals would not start builds automatically.
DA repository trigger on push events, with the tool's approvals recorded as commits to a branch
Incorrect
The tool is not a source code repository, and turning approvals into commits adds a workaround the webhook trigger makes unnecessary.
Cloud Build webhook triggers authenticate and accept incoming webhook events sent to a custom URL that contains an API key and a secret stored in Secret Manager. They connect external systems to Cloud Build and can use an inline build configuration in place of a source repository.
A Cloud Build trigger subscribed to the gcr Pub/Sub topic runs an integration test suite for Artifact Registry images. It now starts a build for every event on the topic, including image deletions and pushes without a tag, and those builds waste worker time. Builds must start only when a tagged image is inserted. How should the team change the trigger?
AAdd an included files filter, such as **/Dockerfile, so that only image changes start a build
BCreate a second subscription on the gcr topic with message ordering, and point the trigger at it
CMap $(body.message.data.tag) and $(body.message.data.action) to substitutions and filter on them
DAdd a first build step that reads the action from the message and exits early unless it is INSERT
Show the answer and why
AAdd an included files filter, such as **/Dockerfile, so that only image changes start a build
Incorrect
Included and ignored files filters apply to repository events; a Pub/Sub trigger sees message payloads, not changed files.
BCreate a second subscription on the gcr topic with message ordering, and point the trigger at it
Incorrect
Ordering changes delivery order only; every event still reaches the trigger and starts a build.
CMap $(body.message.data.tag) and $(body.message.data.action) to substitutions and filter on them
Correct
Substitutions built from the message payload let the trigger filter, for example _IMAGE_TAG != "" && _ACTION == "INSERT", so other events do not start builds.
DAdd a first build step that reads the action from the message and exits early unless it is INSERT
Incorrect
A build still starts for every event and uses a worker before the step exits, which is the waste the team wants to remove.
Pub/Sub triggers can respond to Artifact Registry events on the gcr topic. Define substitution variables from the payload, such as $(body.message.data.tag) and $(body.message.data.action), and add a filter on them; filtering is recommended on topics that carry many messages, so that only matching messages start builds.
A team keeps three copies of a build config that differ only in the
Artifact Registry repository they push to: testing, staging or production,
each in its own location. It wants one file:
steps:
- name: 'gcr.io/cloud-builders/docker'
args: ['build', '-t', '<IMAGE>', '.']
images:
- '<IMAGE>'
What should replace <IMAGE> so that each trigger can choose the repository?
A${_LOCATION}-docker.pkg.dev/$PROJECT_ID/${_REPOSITORY}/${_IMAGE}, with values set per trigger
Bus-docker.pkg.dev/$PROJECT_ID/$REPO_NAME/app, relying on the default $REPO_NAME substitution
Cgcr.io/$PROJECT_ID/app, letting Artifact Registry route each push to the right environment's repository
D$LOCATION-docker.pkg.dev/$PROJECT_ID/app/$BRANCH_NAME, with one branch per environment for each trigger to build
Show the answer and why
A${_LOCATION}-docker.pkg.dev/$PROJECT_ID/${_REPOSITORY}/${_IMAGE}, with values set per trigger
Correct
User-defined substitutions for location, repository and image take their values at build time, so the same file pushes to the repository of each environment.
Bus-docker.pkg.dev/$PROJECT_ID/$REPO_NAME/app, relying on the default $REPO_NAME substitution
Incorrect
$REPO_NAME is the name of the source repository that triggered the build, not the Artifact Registry repository for an environment.
Cgcr.io/$PROJECT_ID/app, letting Artifact Registry route each push to the right environment's repository
Incorrect
A gcr.io path names one repository; nothing in it selects a different repository or location per environment.
D$LOCATION-docker.pkg.dev/$PROJECT_ID/app/$BRANCH_NAME, with one branch per environment for each trigger to build
Incorrect
$LOCATION is the region where the build runs and the path keeps one repository named app, so environments do not get their own repositories and locations.
Cloud Build substitutions let one build config serve several environments. User-defined substitutions start with an underscore, such as ${_LOCATION}, ${_REPOSITORY} and ${_IMAGE}, and get their values from each trigger or from the --substitutions flag; $PROJECT_ID is a default substitution resolved to the build's project.
A company runs part of its production on an Amazon EKS cluster that is
registered to its fleet as a GKE attached cluster with the membership
eks-prod in project ops-fleet. It wants its Cloud Deploy pipeline to deploy
there as well. Which stanza belongs in the new target definition?
Targets for GKE attached clusters use anthosCluster.membership with the membership path, whose location is always global.
Cloud Deploy can deploy to GKE attached clusters, such as EKS or AKS clusters registered to a fleet. Their target configuration is like a GKE target, except that the property is anthosCluster.membership with the path projects/PROJECT/locations/global/memberships/NAME, where the location is always global.