Cloud Build is a powerful, scalable, and cheap way to run your CI/CD builds, but the triggers have some limitations, like branch exclusions.
For example, perhaps you have triggers to:
- Build/deploy the tags to production
- Build/deploy the `master branch to integration
- Build/test feature branches on NOT
You can handle cases 1 & 2 with
tag triggers, but case 3 requires regex exclusions. Unfortunately, this is not an option in Cloud Build triggers.
Regex Contortions to the Rescue
It’s well know that the solution to a regex problem is always more regex.
So, using some negative classes (a bunch of them actually), we can make a NOT
master trigger regex for Cloud Build.
Don’t Forget to Match the Entire Branch
Make sure you match the entire branch name, unless you want to match multiple branches.
^master$” to match master, not “
Otherwise, when Jill checks in her feature branch
jill-css-masterpiece, it will automatically get sent to integration or worse 2.
Match it like you mean it 😉.