DanCat
DanCat

Reputation: 2734

Jenkins Branches to Build - Exclude Single Branch

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

Upvotes: 2

Views: 1438

Answers (2)

Cole9350
Cole9350

Reputation: 5560

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

Upvotes: 3

Vighnesh Pai
Vighnesh Pai

Reputation: 1843

:^(?!(<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.

Upvotes: 2

Related Questions