[Buildbot-devel] doStepIf function

Alexander O'Donovan-Jones Alexander at ccpgames.com
Wed May 26 12:08:21 UTC 2010


Ah, finally managed to work it out. Some context: I wish to send an email if a particular step failed, with relevant information.

###########

from buildbot.status.builder import Results, SUCCESS

def doStepIf(step):
    allSteps = step.build.getStatus().getSteps()
    firstStep = allSteps[0]
    rc = firstStep.getResults()[0] # returns a tuple of (rc, string)
    # if the rc == SUCCESS then don't continue, since we don't want to run this step
    return Results[rc] == Results[SUCCESS]

###########

-----Original Message-----
From: rmdugal at hotmail.com [mailto:rmdugal at hotmail.com] 
Sent: Wednesday, May 26, 2010 11:40 AM
To: Alexander O'Donovan-Jones; Charles Lepple
Cc: buildbot-devel
Subject: Re: [Buildbot-devel] doStepIf function

I have set properties in previous step(s) then the doStepIf function checks 
if those properties have specific values.

--------------------------------------------------
From: "Alexander O'Donovan-Jones" <Alexander at ccpgames.com>
Sent: Wednesday, May 26, 2010 7:23 AM
To: "Charles Lepple" <clepple at gmail.com>; "robert dugal" 
<rmdugal at hotmail.com>
Cc: "buildbot-devel" <buildbot-devel at lists.sourceforge.net>
Subject: RE: [Buildbot-devel] doStepIf function

> Since people have been talking about this, does anyone know the syntax to 
> query the result of a previous step?
> Something like:
>
> def doStepIf(step):
>    return step.build.previousStep.getResults()
>
> I'm banging my head trying to work out the correct way to climb the ladder 
> to get this information :S
>
> -----Original Message-----
> From: Charles Lepple [mailto:clepple at gmail.com]
> Sent: Monday, May 10, 2010 1:01 PM
> To: robert dugal
> Cc: buildbot-devel
> Subject: Re: [Buildbot-devel] doStepIf function
>
> On May 10, 2010, at 8:33 AM, robert dugal wrote:
>
>> I cannot figure out the syntax for how to use doStepIf with a
>> function so that the step is only executed if certain conditions are
>> true. The condition needs to have some complex testing of builder
>> properties so I want to write this as a function.
>> How do I convert something like this below into using a function?
>>
>>            self.addStep(ShellCommand(
>>                 doStepIf=(
>>                 (lambda(step):
>> step.build.getProperties().has_key("FOO"))
>>                 and
>>                 (lambda(step): step.getProperty("FOO") in fooList)
>>                 ), command='some command'))
>
> Something like this:
>
> #########
>
> def do_step_test(step):
>     return step.build.getProperties().has_key("FOO") and
> step.getProperty("FOO") in fooList
>
> self.addStep(ShellCommand(
>     doStepIf = do_step_test,
>     command = 'some command')
>
> #########
>
> To make that work with lambda functions, I think you would need to put
> the "and" inside a single lambda expression. The boolean "and" of two
> function definitions won't get you what you want (not to be confused
> with the *results* of two functions, "and"ed together).
>
> http://docs.python.org/tutorial/controlflow.html#lambda-forms
>
> ------------------------------------------------------------------------------
>
> _______________________________________________
> Buildbot-devel mailing list
> Buildbot-devel at lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/buildbot-devel
>
> 

------------------------------------------------------------------------------

_______________________________________________
Buildbot-devel mailing list
Buildbot-devel at lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/buildbot-devel





More information about the devel mailing list