Google Professional Cloud DevOps Engineer Question 26
Select 4Google Cloud PlatformYour team is migrating an existing CI pipeline to Google Cloud Build. The pipeline includes unit tests, integration tests, and a deployment step. You want to ensure that the Cloud Build configuration is modular and reusable, while also reducing the risk of a failed deployment due to errors. What should you do?
- A
Use multiple steps in the Cloud Build YAML file, separating testing and deployment into distinct steps.
- B
Define reusable custom build steps using Cloud Build custom builders for common tasks like testing and deployment.
- C
Configure Cloud Build triggers to automatically execute the pipeline when code changes are pushed to the repository.
- D
Combine all tasks (testing, integration, and deployment) into a single build step to simplify the YAML configuration.
- E
Use Cloud Build substitutions to parameterize the pipeline for different environments (e.g., staging and production).
Show answer and explanation
Correct answers: A, B, C, E
Explanation
To implement an effective CI pipeline using Cloud Build, it is critical to follow best practices such as modularizing your pipeline steps (e.g., separating testing and deployment), utilizing reusable custom builders for common tasks, automating the pipeline via triggers, and using substitutions to support multiple environments. Combining all tasks into a single step is discouraged, as it reduces flexibility and makes troubleshooting more challenging.
- A. Correct.
Correct. Separating testing and deployment into distinct steps in the Cloud Build YAML file improves the modularity and readability of the pipeline, while also making it easier to identify and fix issues in specific steps.
- B. Correct.
Correct. Custom builders allow you to encapsulate common tasks, making the pipeline more reusable and reducing duplication.
- C. Correct.
Correct. Configuring triggers automates the pipeline execution, ensuring it runs consistently whenever there are changes, which is a key CI principle.
- D. Incorrect.
Incorrect. Combining all tasks into a single step reduces modularity, makes debugging more difficult, and goes against best practices for Cloud Build pipeline design.
- E. Correct.
Correct. Substitutions allow you to parameterize the pipeline, making it flexible for different environments (e.g., staging, production) without duplicating configuration.