PROFESSIONAL-CLOUD-DEVELOPER · Question #87
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…
The correct answer is D. Create a Cloud Build build config file with separate cloud builder steps to compile and execute. Creating a Cloud Build config file (cloudbuild.yaml) with separate, discrete build steps for compiling, unit testing, and integration testing is the best approach. Each step runs in its own container and is recorded independently in the build history. When a failure occurs…
Question
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?
Options
- AAdd RUN commands in the Dockerfile to execute unit and integration tests.
- BCreate a Cloud Build build config file with a single build step to compile unit and integration tests.
- CCreate a Cloud Build build config file that will spawn a separate cloud build pipeline for unit and
- DCreate a Cloud Build build config file with separate cloud builder steps to compile and execute
How the community answered
(36 responses)- A11% (4)
- B6% (2)
- C3% (1)
- D81% (29)
Explanation
Creating a Cloud Build config file (cloudbuild.yaml) with separate, discrete build steps for compiling, unit testing, and integration testing is the best approach. Each step runs in its own container and is recorded independently in the build history. When a failure occurs, Cloud Build marks exactly that step as failed, making it immediately visible which stage broke. Adding RUN commands in the Dockerfile (A) bundles everything into one opaque layer. A single build step (B) loses granularity - a failure anywhere shows as one undifferentiated failure. Spawning a separate pipeline (C) adds unnecessary complexity and makes tracing failures harder, not easier.
Topics
Community Discussion
No community discussion yet for this question.