A development team wants to automatically run unit tests and static code analysis on every push to a Cloud Source Repository, but only run integration tests on merges to the main branch. Which Cloud Build trigger configuration should they use?
Trap 1: Use a single trigger with a substitution variable like '_BRANCH'…
Substitutions are set at trigger creation, not at runtime based on branch.
Trap 2: Create one trigger with a build config that uses the 'branchName'…
Cloud Build does not support conditional step skipping based on substitutions.
Trap 3: Configure one trigger with no branch filter and rely on developers…
Defeats automation; manual triggers are not the intended solution.
- A
Use a single trigger with a substitution variable like '_BRANCH' and set it to 'main' for integration tests.
Why wrong: Substitutions are set at trigger creation, not at runtime based on branch.
- B
Create one trigger with a build config that uses the 'branchName' substitution to conditionally skip integration test steps.
Why wrong: Cloud Build does not support conditional step skipping based on substitutions.
- C
Create two triggers: one with a branch filter for '^main$' that runs integration tests, and another with a branch filter for '^.*$' that runs unit tests.
Correct: separate triggers with branch filters allow different pipelines per branch.
- D
Configure one trigger with no branch filter and rely on developers to manually trigger integration tests.
Why wrong: Defeats automation; manual triggers are not the intended solution.