[Buildbot-devel] Adding interpolated property in a build step
Alexander Sack
pisymbol at gmail.com
Thu Jul 26 14:18:13 UTC 2012
On Thu, Jul 26, 2012 at 10:05 AM, Tom Prince <tom.prince at ualberta.net> wrote:
> Alexander Sack <pisymbol at gmail.com> writes:
>
>> Hello:
>>
>> I have read that build steps can set properties. I'd like to have a
>> step set a build property that will be interpolated at run-time and
>> then re-used by another build step.
>>
>> Step X - create a file based on some interpolated properties, save the
>> filename which is based on interpolated values in the build
>> Step Y - use filename property
>>
>> The doc talks about setting shell based env and command based output.
>> But how do I set a simple property from within a build step? And can
>> I use WithProperties()?
>
> It is easy to write a build step that does this:
>
> class SetProperty(BuildStep):
> renderables = [properties]
> def __init__(self, name, **properties):
> BuildStep.__init__(self, name=name)
> self.properties = properties)
> def start(self):
> for k, v in properties:
> self.setProperty(k, v, self.name)
> self.finish(SUCCESSS)
>
> This code is untested, and would need more polish to be added upstream,
> but demonstrates the basic idea (and simplicity of writing custom
> buildsteps).
Tom, first of all thanks for this. I originally tried a horrible
variant of this:
bstep = BuildStep()
prop = IProperties(bstep)
prop.setProperty(n, v, '')
but this died because it could not adapt bstep with IProperties
(despite the fact that the BuildStep has a mixin to do this).
This is my lack of understanding on how the core code is organized (be
kind it was 2 minute hack attempt after looking at some internal
code).
The 'echo' trick works but is a bit silly. Let me try the above in my
test build env. This kind of step seems like a no brainer to me.
Still learning,
-aps
More information about the devel
mailing list