PCD Building and testing applications

A cloudbuild.yaml file has three steps in this order: build the image, push the image, then run unit tests. The tests sometimes fail, but by then the image has already been pushed. How should the pipeline be changed?

Show answer and explanation

Answer: D

Cloud Build executes steps in order and stops the build when a step exits with a non-zero status. Running the tests first means a failure halts the pipeline before any image is built or pushed to the registry.

Why the other options are wrong

  • A. Testing after the push means the failing image already sits in the registry, where it can still be pulled by anything that references it.
  • B. allowFailure makes the build continue past a failed step, which hides test failures and lets a broken image move forward.
  • C. Testing after production deployment means defects reach users first, which defeats the purpose of running tests before release.

Keep going. 135 PCD questions, answers explained after each one.

Practise this domain

Reviewed November 2026. Spotted a problem with this question? Report it from the practice tool.