[Buildbot-devel] Not executing a step if the build is about to fail
Sergey A. Lipnevich
sergey at optimaltec.com
Sun Aug 10 16:54:08 UTC 2008
Sergey A. Lipnevich wrote:
> Hi,
>
> I have a build that has the following structure:
> prepare (halt on failure)
> before (halt on failure)
> build (flunk on failure)
> after (flunk on failure)
> package (flunk on failure)
> kick off more builds without waiting for completion
>
> I'd like "package" and "kick off more builds" steps not to run if
> anything in front of them in the chain fails (mostly, if "build" fails).
> At the same time, if "before" succeeds, "after" *must* run. In effect, I
> need a "don't run this step if build as a whole is guaranteed to fail"
> flag. What would be the best way to accomplish this?
Here's what I came up with. I subclass a step that needs the logic
described above, and do something along these lines:
from buildbot.status.builder import SKIPPED, SUCCESS, WARNING
from buildbot.steps.shell import ShellCommand
class MyStep(ShellCommand):
# __init__ here...
def start(self):
'''Don't start if the build is going to fail.'''
if self.build.result in (SUCCESS, WARNING):
return ShellCommand.start(self)
return SKIPPED
Also, a property can be analyzed easily:
def start(self):
'''Only run on trunk.'''
if self.build.result in (SUCCESS, WARNING):
try:
if 'trunk' == self.getProperty('branch'):
return ShellCommand.start(self)
except KeyError:
pass
return SKIPPED
HTH,
Sergey.
More information about the devel
mailing list