Currently, using the setup displayed below, Jenkins builds master and all *-preview branches. Using Branches to build, is it possible for Jenkins to exclude a single *-preview branch such as exclude-this-branch-preview while building all remaining *-preview branches?
2 Answers
You can use regex by specifying a semi-colon before
:^(?!exclude-this-branch-preview).*-preview$ From the help:
:<regular expression> The syntax is of the form: :regexp. Regular expression syntax in branches to build will only build those branches whose names match the regular expression. Examples: :^(?!(origin/prefix)).* matches: origin or origin/master or origin/feature does not match: origin/prefix or origin/prefix_123 or origin/prefix-abc :origin/release-\d{8} matches: origin/release-20150101 does not match: origin/release-2015010 or origin/release-201501011 or origin/release-20150101-something :^(?!origin/master$|origin/develop$).* matches: origin/branch1 or origin/branch-2 or origin/master123 or origin/develop-123 does not match: origin/master or origin/develop 2 Comments
DanCat
What does the leading
? on :^(?!exclude-this-branch-preview).*-preview$ imply?Cole9350
@DanCat The
?! is negative look ahead, which basically means must not match. stackoverflow.com/questions/12210807/what-does-mean