[Buildbot-devel] How to check if build has property on buildbot 0.8.10?

Giovanni Gherdovich g.gherdovich at gmail.com
Mon Feb 9 17:48:24 UTC 2015


Hello Pierre,

thank you for your reply.

> Did you try step.hasProperty() ?
> or "prop" in step.getProperties() ?

I think all forms work, the two you mention and even the outated "has_key"

https://github.com/buildbot/buildbot/blob/buildbot-0.8.10/master/buildbot/process/properties.py#L134

I eventually narrowed my problem down to WithProperties (which was the way
to go in 0.8.1
but now deprecated). This used to work in 0.8.1 but apparently now is
broken:

--------------------------------------
factory = BuildFactory()
factory.addStep(ShellCommand(command=WithProperties("echo %(foo)s")))
--------------------------------------

(note: I don't provide a default value for the interpolation).
That's where the error comes from in my example.

I was a bit surprised that this other doesn't work as well:

--------------------------------------
factory = BuildFactory()
factory.addStep(ShellCommand(command=WithProperties("echo %(foo)s"),
                             doStepIf=lambda step: step.hasProperty('foo')))
--------------------------------------

My intuition was "ok, no default, but if the prop isn't there you don't run
it,
so I am good". And then I confused things and tought the error was from
accessing the property.

I can make WithProperty to work by providing a default value:

--------------------------------------
factory = BuildFactory()
factory.addStep(ShellCommand(command=WithProperties("echo %(foo:-)s")))
--------------------------------------

but I'll just stop using it and go for Interpolate.

Cheers,
GGhh
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://buildbot.net/pipermail/devel/attachments/20150209/62ca1df2/attachment.html>


More information about the devel mailing list