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.
Add 'Inverse' choosing strategy which ignores specified branches.
Also add documentation and improve the existing strategy documentation.
Internationalise DefaultBuildChooser display name.
Since you Doximity types are so keen, here's a build of the plugin including this feature:
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.
"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 :)
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.
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
This didn't work :(
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?
Ensure 'all branches excluded' message is shown only when that is true.
Also add a message when there's nothing new to build, so the last-built branch is selected.
Ensure HEAD BranchSpec reference is retained, rather than being trans…
I fixed a possible NPE and improved the log messages shown.
Updated build is here:
How can I use this to ignore two branches? (e.g. build every branch except master and release)
@erikackermann I am looking for the exact same thing, maybe @orrc knows how to do that?
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).
does this still work? Even if I specify branches (with/without wildcard) with inverse strategy, still the most-recently updated branch will be built
@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.