[Buildbot-devel] Using Properties numerically

Tom Prince tom.prince at ualberta.net
Fri May 4 18:56:57 UTC 2012


On Fri, 4 May 2012 10:08:20 -0700, Richard Offer <richard at whitequeen.com> wrote:
> I need/want to be able to use a property value numerically, i.e.
> 
>         set_properties = { 
>             'SAUSAGEBOT_BUILDID' : 40000 + int( buildbot.process.properties.WithProperties("%(buildnumber:-0000)s") ), 
>         },

You can use Property instead of WithProperties to get a number, assuming
that the property was originally specified as number (i.e. not set by
SetProperties, for example).

But, that won't allow you do arithmetic with it like you show above. The
trouble is that the code written is evaluated at configure time, but you
need the calculation done at build time. The way to do that, is to write
an IRenderable instance that does what you want. (This basically
involves writting a class with a method getRenderingFor.

> Our existing build code (using bamboo) is all environment variable
> driven, trying to get Properties in sync with environment variables
> has proved to be magic - and not the good type…

You don't necessarily need to keep them in sync. You can specify
environment varialbes on the slave or builder or on indivual build
steps. And if you want these to depend on properties, you can use
WithProperties in the dicts these take.

> I think the complexity has been trying to provide support for both
> individual and system builds (the system build triggers all the
> individual builds) - and I want to be able to use a single top level
> build-id for all generated products (split across each of the
> builders) - and that id is not the revision version.
> 
> The "from the 1week newbie" take away is that the documentation and
> examples around properties and their interaction with the system might
> be better explained… I never could get SetPropertiesFromEnv to work
> (probably because I wanted it on the slave not master).

Certainly, the current documentation is lacking here. The handling of
properties has become more flexible in the last few versions, and the
documentation hasn't kept up. I hope to get some improved documentation
written for 0.8.7. Any comments would be apprecieated.

SetPropertiesFromEnv looks at the environment on the slave (which is the
environment from which it is launched. One common source of confusion is
that each BuildStep is run in a seperate shell, so that changes to the
enviroment/working directory aren't propagated to other steps (in your
case not SetPropertiesFromEnv).

> Is there a way to configure the initial buildnumber on a one off basis
> ? I don't want it to start from 0 when I roll this into production - I
> don't what to confuse people with a lower build number than the system
> I'm replacing…

Therer isn't any direct way to do this, but it might be possible to
manage it by poking around in the manhole.  In general, I wouldn't
suggest this, but for a one-of configuration this is probably not
entirely unreasonable.

  Tom




More information about the devel mailing list