Ticket #428 (closed enhancement: fixed)
ability to run shellCommand based on a conditional property
| Reported by: | mook | Owned by: | |
|---|---|---|---|
| Priority: | minor | Milestone: | 0.7.11 |
| Version: | 0.7.9 | Keywords: | sprint |
| Cc: | catlee, jhoos |
Description
It would be nice if I could skip commands (or build steps in general?) based on having some property set (or unset, etc.). Attached is a (untested) patch that does something like this for shellCommand (would be nicer if it's more generic, I guess?). Unfortunately, I couldn't quite figure out the unit test system yet, so don't trust this code, please.
Attachments
Change History
Changed 4 years ago by mook
-
attachment
0001-add-conditional-shellCommand-untested.patch
added
comment:1 Changed 4 years ago by dustin
- Milestone changed from undecided to 0.7.10
I like, but can it take a "test" function, e.g.,
f.addStep(ConditionalShellCommand(
conditionFn=lambda props : props['foo'] in ('bar', 'baz'),
command=...))
putting this in the 0.7.10 milestone in hopes it can be done in time. If not, that's OK :)
comment:3 Changed 4 years ago by dustin
- Milestone changed from 0.7.+ to 0.7.11
Let's get this in 0.7.11, eh?
comment:4 Changed 4 years ago by catlee
- Cc catlee added
I'd like to see this be able to run any build step conditionally, not just shell commands.
And it definitely needs to accept a "test" function.
comment:6 Changed 4 years ago by jhoos
I stumbled across this ticket earlier this week, and it so happens that we have a patch that implements the ability to conditionally run any step based on a function or lambda. We named the parameter "doStepIf" instead of "conditionFn", but otherwise it should fit the bill. If the function/lambda returns true, the step is run normally, otherwise the step returns SKIPPED and its start method is not called. The only other difference is that in our implementation the lambda takes the entire step object as its parameter, instead of just the properties.
Changed 4 years ago by jhoos
-
attachment
buildbot-0.7.10p1-conditional-steps.patch
added
Conditional steps based on lambdas, with unit test
comment:8 Changed 4 years ago by dustin
- Status changed from new to closed
- Resolution set to fixed
I changed the "== False" to just use "not", since doStepIf may return other false values.
714 if isinstance(self.doStepIf, bool): 715 if not self.doStepIf: 716 skip = SKIPPED 717 elif not self.doStepIf(self): 718 skip = SKIPPED
committed:
commit 830cb403ad59dff5da6102000827f90349dbfedd
Author: Jason Hoos <jason.hoos@syclo.com>
Date: Sun Apr 12 13:39:41 2009 -0400
(refs #428) add doStepIf parameter to buildsteps
Thank you for contributing!
comment:10 Changed 3 years ago by dustin
commit 5d65dc65a03ec3a38648c42407f3163de3310aa6
Author: Dustin J. Mitchell <dustin@zmanda.com>
Date: Sat Dec 26 19:22:05 2009 -0600
document doStepIf
![[Buildbot Logo]](/chrome/site/header-text-transparent.png)
untested patch