[Buildbot-devel] Adding interpolated property in a build step

Benoît Allard benoit at aeteurope.nl
Tue Jul 31 08:33:05 UTC 2012


Hi Alexander,

> -----Original Message-----
> From: Alexander Sack [mailto:pisymbol at gmail.com]
> Okay the exact code that worked for me:
>
> 8 class SetBuildProperty(BuildStep):
> 9     """ Set a build property as a step """
> 10
> 11     renderables = ['properties']
> 12
> 13     def __init__(self, name = 'buildproperty', **properties):
> 14         BuildStep.__init__(self, name=name)
> 15         self.properties = properties
> 16
> 17     def start(self):
> 18         for k, v in self.properties.iteritems():
> 19             self.setProperty(k, v, self.name)
> 20         self.finished(SUCCESS)
>
> Usage:
>
> SetBuildProperty(foo = WithProperties(%(bar)s.patch')
>
> Again, thank you.  I really believe this should be added as a core
> feature of ANY BuildStep (minimally the above should be part of the
> base).
>

A more common usage, (at least here), is to set a property based on some extract 
of the output of the command being run.

An example of this:


    47     def commandComplete(self, cmd):
    48         log = cmd.logs['stdio'].getText()
    49
    50         # name of project generated
    51         m = re.search(r'PROJECT:\s+(\S+)', log)
    52         if m: 
    53             self.setProperty("project.name",
    54                              m.group(1), self.name)

This ask you to tweak a bit more your steps, but then you don’t have to add an extra one.

Regards,
Benoît.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/pkcs7-signature
Size: 6467 bytes
Desc: not available
URL: <http://buildbot.net/pipermail/devel/attachments/20120731/10ad8c92/attachment.bin>


More information about the devel mailing list