But the build never starts when you push to main. What is the likely error?
medium
A. The build steps are missing the Docker build command
B. The trigger YAML is missing the substitutions field
C. The trigger must specify a tagName instead of branchName
D. branchName should be a regex like "^main$"
Solution
Step 1: Check branchName format in trigger
Cloud Build expects branchName as a regex pattern, not plain string.
Step 2: Correct branchName to regex
Changing branchName to "^main$" matches exactly the main branch and triggers build.
Final Answer:
branchName should be a regex like "^main$" -> Option D
Quick Check:
branchName needs regex = branchName should be a regex like "^main$" [OK]
Hint: branchName must be regex, not plain text [OK]
Common Mistakes:
Using plain branch name without regex anchors
Confusing branchName with tagName
Thinking substitutions are mandatory
5. You want to create a build trigger that starts only when a tag matching v* is pushed, and the build should run two steps: first build a Docker image, then deploy it. Which YAML snippet correctly configures this trigger?