How to trigger Cloud Build for code changes?
Short answer
B Configure a Cloud Build trigger with the event set as "Push to a branch"
Question
Key Takeaways
This question tests the selection of the correct Cloud Build trigger event to capture all code changes, where the trap is choosing 'Pull Request' (Option A) which misses direct pushes, or Cloud Functions which are overkill for standard CI.
To automate ML model retraining in Google Cloud, use Cloud Build triggers integrated with Cloud Source Repositories. The community consensus confirms that setting the trigger event to 'Push to a branch' ensures the pipeline runs on every code modification.
Common mistake: Selecting Option A (Pull Request) is a common mistake because, while useful for testing, it does not cover direct pushes to branches, failing the requirement to retrain on 'any modification.'
Expert Analysis
Why the Answer Is Correct
Option B is correct because Cloud Build is Google Cloud's native, fully managed CI/CD platform designed to automate builds and deployments. Configuring a trigger on 'Push to a branch' ensures that the pipeline activates whenever new code is committed to any branch, strictly satisfying the requirement to retrain models on 'any modification' of the code.
Why the Other Options Are Wrong
Option A is incorrect because triggering on 'Pull Request' limits automation to only those changes associated with a PR, missing direct commits to the main branch. Options C and D are incorrect because implementing a Cloud Function to handle builds is unnecessarily complex and less efficient than using the native Cloud Build integration, which handles repository events automatically.
Community Comment Notes
Community members emphasize that Cloud Build is the ideal tool for this task due to its seamless integration with Cloud Source Repositories. Several comments highlight that 'Push to a branch' is the superior choice over 'Pull Request' because it captures all code changes, including direct pushes to the main branch. While one comment noted the potential resource intensity of retraining on every push, Option B remains the technically correct answer to meet the specific criteria of the question.
Official Reference
https://cloud.google.com/build/docs/automating-builds/create-manage-triggers
This link opens the official vendor documentation in a new tab.
Exam Strategy
When questions ask for actions on 'any modification' or 'every change,' look for 'Push' events rather than 'Pull Request' events to ensure comprehensive coverage. Always prioritize native integrations like Cloud Build triggers over custom solutions like Cloud Functions for standard CI/CD scenarios.
Community Votes
100% of anonymous learners picked answer B. Votes are pick records left by other test-takers — they are not the verified answer.
Discussion 6 contributions
Compiled from public community threads and reader submissions, lightly edited for clarity. Handles and vote tallies are shown as recorded, and comments reflect the views of individual contributors.
From public community threads 6
-
pikachu007 👍 4 Answered BCloud Build Integration: Cloud Build is Google Cloud's fully managed CI/CD platform, designed to automate builds and deployments, making it ideal for this task. Trigger on Code Pushes: Setting the trigger event to "Push to a branch" ensures that the pipeline automatically activates whenever new code is pushed to any branch of the repository, aligning with the goal of retraining models on code modifications.
-
fitri001 👍 2 Answered BContinuous Integration: CI pipelines aim for frequent integration of code changes. Triggering the build pipeline upon every push to a branch (including the main branch) ensures your models retrain whenever the code relevant to them is modified. Focus on Relevant Changes: Compared to option A ("Pull Request"), triggering on pushes allows retraining even for direct pushes to the main branch, not just pull request merges. This can be crucial for catching critical code changes that might bypass pull requests.
-
guilhermebutzke 👍 1 Answered BMy Answer B: For ANY modifications, “Push to a branch” is the best choice in Cloud Build trigger. However, when it comes to ML model training, retraining models on every push might be resource-intensive, especially if the training process is computationally expensive. So, I think triggering the CI pipeline on a pull request allows for changes to be tested before merging into the main branch. would be a better choice …
-
pinimichele01 👍 1 Answered BFor ANY modifications, “Push to a branch” is the best choice in Cloud Build trigger.
-
b1a8fae 👍 1 Answered BB. Any code change on the Cloud repo is done by pushing to a branch.
Show 1 more comment
-
forport 👍 1 Answered BB. According to Gemini-Advanced.
Reader comments & corrections
No reader corrections yet — spotted an error or have a note? Share it below.
Related Analysis
Practice All PMLE Questions
Access 65 questions with complete answers and detailed explanations.
View Full PMLE Practice Test →