问题
I want to be able to build all branches that are not master, however when I try ^((?!master).)*$
the UI correctly shows all non-master branches but saving returns a HTTP 400 error.
{
"error": {
"code": 400,
"message": "trigger_template branch_name is not a valid regular expression",
"status": "INVALID_ARGUMENT"
}
}
回答1:
this is stupid ... but works by ignoring everything that starts with "master"
^(?:[^m]|m[^a]|ma[^s]|mas[^t]|mast[^e]|maste[^r]|master.)
回答2:
The regex used must be compatible with Go's regex library, which this one is not. (It is compatible with JavaScript, which is why the UI works with it.) https://regex101.com/ is useful for playing with different language parsers. (A teammate just showed it to me.) Go's regex documentation is on GitHub.
来源:https://stackoverflow.com/questions/44008616/google-cloud-builder-how-to-build-all-branches-except-for-master