Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Merged
merged 4 commits into from Oct 25, 2011

Conversation

Projects
None yet
@orrc
Copy link
Member

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

This comment has been minimized.

Copy link

commented Sep 26, 2011

❤️

@jeyb

This comment has been minimized.

Copy link

commented Sep 26, 2011

+1

1 similar comment
@smcpherson

This comment has been minimized.

Copy link

commented Sep 26, 2011

+1

@unicornrainbow

This comment has been minimized.

Copy link

commented Sep 26, 2011

:shipit:

@pelle

This comment has been minimized.

Copy link

commented Sep 26, 2011

+1

@orrc

This comment has been minimized.

Copy link
Member Author

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

This comment has been minimized.

Copy link

commented Sep 26, 2011

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

This comment has been minimized.

Copy link
Member Author

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

This comment has been minimized.

Copy link

commented Sep 26, 2011

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

This comment has been minimized.

Copy link
Member

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

This comment has been minimized.

Copy link

commented Oct 4, 2011

This didn't work :(

@orrc

This comment has been minimized.

Copy link
Member Author

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

This comment has been minimized.

Copy link

commented Oct 5, 2011

I used */master

On Oct 4, 2011, at 3:31 PM, Christopher Orr
reply@reply.github.com
wrote:

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?

Reply to this email directly or view it on GitHub:
#45 (comment)

orrc added some commits Oct 6, 2011

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.
@orrc

This comment has been minimized.

Copy link
Member Author

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

This comment has been minimized.

Copy link

commented Oct 20, 2011

+1

ndeloof added a commit that referenced this pull request Oct 25, 2011

Merge pull request #45 from orrc/inverse-strategy
Add 'Inverse' choosing strategy which ignores specified branches

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

@erikackermann

This comment has been minimized.

Copy link

commented Jan 31, 2014

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

@vvo

This comment has been minimized.

Copy link

commented Feb 6, 2014

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

**/master|otherbranch ?

@orrc

This comment has been minimized.

Copy link
Member Author

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

This comment has been minimized.

Copy link

commented Jan 26, 2016

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

This comment has been minimized.

Copy link

commented Jan 27, 2016

@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
You can’t perform that action at this time.