Google Professional Cloud DevOps Engineer Question 192
Select 4Google Cloud PlatformYour team uses Cloud Build for continuous integration (CI) and has recently implemented a new policy to ensure all code changes are thoroughly tested before being merged into the main branch. To enforce this, you need to configure Cloud Build to execute unit tests automatically for every pull request and only allow merging if the tests pass. Additionally, you want to ensure that build logs are easily accessible for debugging any failed runs. Which combination of steps should you take to achieve this?
- A
Configure a trigger in Cloud Build that runs on pull request events targeting the main branch.
- B
Write a Cloud Build configuration file defining steps to execute unit tests and upload test artifacts.
- C
Enable the 'Require status checks to pass before merging' option in your repository.
- D
Deploy a custom Cloud Function to analyze build logs and notify developers of failures.
- E
Enable Cloud Logging for Cloud Build to centralize and access build logs.
Show answer and explanation
Correct answers: A, B, C, E
Explanation
To enforce a CI process where unit tests are automatically run for every pull request and merging is blocked unless tests pass, you need to configure a pull request trigger in Cloud Build, define the testing steps in a Cloud Build configuration file, and enable the 'Require status checks to pass before merging' option in the repository. Additionally, enabling Cloud Logging ensures that build logs are centralized and accessible for debugging. Deploying a custom Cloud Function is unnecessary for this specific scenario, as Cloud Build and the repository settings already provide the required functionality.
- A. Correct.
This is correct. Configuring a pull request trigger ensures that builds are automatically initiated for every pull request targeting the main branch.
- B. Correct.
This is correct. A Cloud Build configuration file is necessary to define the steps for executing unit tests and managing test artifacts.
- C. Correct.
This is correct. Enabling the 'Require status checks to pass before merging' option ensures that code cannot be merged into the main branch unless the build and tests are successful.
- D. Incorrect.
This is incorrect. While notifying developers is a helpful practice, deploying a custom Cloud Function is not a required or standard step to achieve the desired outcome in this scenario.
- E. Correct.
This is correct. Enabling Cloud Logging makes it easier to access and debug build logs in case of failures.