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
Merged

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

merged 4 commits into from
Oct 25, 2011

Conversation

orrc
Copy link
Member

@orrc 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
Copy link

maletor commented Sep 26, 2011

❤️

@jeyb
Copy link

jeyb commented Sep 26, 2011

+1

1 similar comment
@smcpherson
Copy link

+1

@unicornrainbow
Copy link

:shipit:

@pelle
Copy link

pelle commented Sep 26, 2011

+1

@orrc
Copy link
Member Author

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
Copy link

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
Copy link
Member Author

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
Copy link

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
Copy link

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
Copy link

maletor commented Oct 4, 2011

This didn't work :(

@orrc
Copy link
Member Author

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
Copy link

maletor 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)

Also add a message when there's nothing new to build, so the last-built branch is selected.
@orrc
Copy link
Member Author

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
Copy link

steel commented Oct 20, 2011

+1

ndeloof added a commit that referenced this pull request Oct 25, 2011
Add 'Inverse' choosing strategy which ignores specified branches
@ndeloof ndeloof merged commit ae23c65 into jenkinsci:master Oct 25, 2011
@erikackermann
Copy link

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

@vvo
Copy link

vvo commented Feb 6, 2014

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

**/master|otherbranch ?

@orrc
Copy link
Member Author

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
Copy link

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
Copy link
Contributor

@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
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.