2

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?

enter image description here

2 Answers 2

3

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 
Sign up to request clarification or add additional context in comments.

2 Comments

What does the leading ? on :^(?!exclude-this-branch-preview).*-preview$ imply?
@DanCat The ?! is negative look ahead, which basically means must not match. stackoverflow.com/questions/12210807/what-does-mean
2
:^(?!(<the branch name to be excluded with out angular braces>)).* 

Put this in the branches to build and try SCM polling. Its a regular expression, self explanatory.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.