How do I configure Jenkins to build all branches except a few which I exclude?
How about using
^(?!.*master).*$
as branch specifier. This regexp means all branches not matching master.
Breakdown:
^(?!.*master).*$^ ---> beginning of string (?! ) ---> negative lookahead find all that doesnt match .* ---> zero or more of 'any' character master ---> should not match master .*$ ---> will match anything to the end of string
I needed using the Jenkins tool "filter branch by regex", and I discovered flavor of that regex works just with back reference.So, following the Jesper response and this issue, here I did two more examples:
^(?:.*release\/\d+.\d+.\d+(?!.))$// check all branches like "release/0.0.0" or "origin/release/1.2.3"^(?:.*release\/\d+.\d+.\d+_any)$// check all branches like "release/0.0.0_any" or "origin/release/1.2.3_any"
I hope this would helpful for someone
EDIT - New example
^(?:origin\/develop|origin\/master|origin\/release\/\d+\.\d+\.\d+(?!.)|origin\/release\/\d+\.\d+\.\d+(?:_uat|_preprod))$
or
^(?:.*develop|.*master|.*release/\d+\.\d+\.\d+(?!.))$