Google Cloud Professional Cloud Developer — Question 34

You are using Cloud Build to build a Docker image. You need to modify the build to execute unit and run integration tests. When there is a failure, you want the build history to clearly display the stage at which the build failed.
What should you do?

Answer options

Correct answer: D

Explanation

The correct answer is D because creating separate cloud builder steps allows for clear identification of which stage failed in the build process, helping with debugging. Option A is incorrect as adding RUN commands in the Dockerfile does not provide clear separation or tracking of test failures. Option B simplifies the process too much and does not allow for distinct failure stages, while option C adds unnecessary complexity by spawning a separate pipeline instead of utilizing steps within the same build.