Google Professional Cloud DevOps Engineer Question 59
Single answerGoogle Cloud PlatformYour organization is using Google Cloud Build for continuous integration and deployment. You have been tasked with setting up a CI/CD pipeline that automatically starts a build whenever there is a new commit to the main branch of your repository in Cloud Source Repositories. Which trigger configuration should you use?
- A
Create a Cloud Build trigger with an event type set to 'Push to a branch' and specify the branch as 'main'.
- B
Create a Cloud Build trigger with an event type set to 'Pull request' and specify the branch as 'main'.
- C
Manually start a Cloud Build job whenever there is a new commit to the repository.
- D
Create a Cloud Build trigger with an event type set to 'Tag' and specify a tag pattern matching 'v*'.
Show answer and explanation
Correct answer: A
Explanation
To set up an automated CI/CD pipeline in Google Cloud Build that triggers on new commits to the 'main' branch, you need to configure a trigger with the event type 'Push to a branch' and specify the branch as 'main'. This ensures that every time a commit is pushed to the 'main' branch, a new build is automatically initiated. Other event types, such as 'Pull request' or 'Tag', are for different use cases and would not meet the requirements specified in the scenario.
- A. Correct.
This is the correct option. A Cloud Build trigger with an event type set to 'Push to a branch' and specifying the branch as 'main' ensures that the pipeline is triggered whenever new commits are pushed to the 'main' branch.
- B. Incorrect.
This is incorrect. A 'Pull request' event type is used to trigger builds when a pull request is created or updated, not for direct commits to a branch.
- C. Incorrect.
This is incorrect. Manually starting a Cloud Build job is not automated and does not align with the principles of a CI/CD pipeline.
- D. Incorrect.
This is incorrect. A 'Tag' event type triggers builds based on specific tags, not commits to a branch.