Skip to content

Add 'Inverse' choosing strategy which ignores specified branches #45

Merged
merged 4 commits into from Oct 25, 2011
@orrc
Jenkins member
orrc commented Sep 25, 2011

For feature branches etc, I wanted a way to build everything except for master (and also someone asked about it on StackOverflow recently). Seems like a relatively common/useful feature.

So here's a choosing strategy which looks at "Branches to build" and promptly ignores them all -- only branches which do not match the configured branch specifiers will be built.

I've given this a reasonable test, and half the code is based on the DefaultBuildChooser anyway, so hopefully this implementation makes sense.

I also updated the original inline help to be a bit more explanatory.

@maletor
maletor commented Sep 26, 2011

:heart:

@jeyb
jeyb commented Sep 26, 2011

+1

@smcpherson

+1

@pelle
pelle commented Sep 26, 2011

+1

@orrc
Jenkins member
orrc commented Sep 26, 2011

Since you Doximity types are so keen, here's a build of the plugin including this feature:
https://github.com/downloads/orrc/git-plugin/git.hpi

@unicornrainbow

Would it be possible for the build chooser to accept regex? Seems like that would solve the same problem as this, but in a different manner that may be more flexible. Just a thought.

@orrc
Jenkins member
orrc commented Sep 26, 2011

"Now you have two problems."
Writing inversions as regular expressions is a bit annoying.

But if you wanted a feature like that, you'd have to ask the core developers -- probably it would have a number of knock-on effects in how these BuildChooser implementations function, and so on.

The git plugin will likely get a rewrite at some point, so I probably wouldn't hold my breath unless you tackle it yourself :)

@unicornrainbow

Yeah, I suppose it could be more trouble then it's worth. Essentially, what you've built will get the job done for what we need. Thanks.

@stisti
Jenkins member
stisti commented Sep 27, 2011

Heh, just today I was saying at work how great it would be if the git plugin could be configured to ignore the master branch and work on all the other branches. +1

@maletor
maletor commented Oct 4, 2011

This didn't work :(

@orrc
Jenkins member
orrc commented Oct 4, 2011

This does work :)

I just took a clean Jenkins installation, created a job, entered the Git URL, entered "**/master" as the branch, chose this "Inverse" strategy, hit Save and started some builds. All branches except for master were built.

Can you be more specific?

@maletor
orrc added some commits Oct 6, 2011
@orrc
Jenkins member
orrc commented Oct 12, 2011

I fixed a possible NPE and improved the log messages shown.

Updated build is here:
https://github.com/downloads/orrc/git-plugin/git.hpi

@steel
steel commented Oct 20, 2011

+1

@ndeloof ndeloof merged commit ae23c65 into jenkinsci:master Oct 25, 2011
@erikackermann

How can I use this to ignore two branches? (e.g. build every branch except master and release)

@vvo
vvo commented Feb 6, 2014

@erikackermann I am looking for the exact same thing, maybe @orrc knows how to do that?

**/master|otherbranch ?

@orrc
Jenkins member
orrc commented Feb 6, 2014

You'd have to modify the plugin to do that, or write another choosing strategy.
As far as I recall, the change I added here does an exact match (well, plus wildcards).

@fabiankoebel

does this still work? Even if I specify branches (with/without wildcard) with inverse strategy, still the most-recently updated branch will be built

@MarkEWaite

@fkoebel-letsdev, I don't think that asking a question as part of this merged and closed pull request will get as many responses as if you ask the same question on the jenkins users mailing list. There are far more people subscribed to the jenkins users mailing list than are subscribed to this pull request.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.