[Buildbot-devel] Custom functions in master.cfg

Dmitry Nezhevenko dion at dion.org.ua
Mon Jul 23 08:58:05 UTC 2012


On Mon, Jul 23, 2012 at 09:09:04AM +0200, Christoph Spielmann wrote:
> Hi,
> 
> In my configuration i defined the following function to create a string 
> in the form "0_Sunday",..., "6_Saturday":
> 
> from datetime import date
> import locale
> 
> def createUploadTargetDirectory():
>       locale.setlocale(locale.LC_ALL,'de_DE')
>       d=date.today()
>       return "{0}_{1}".format(((d.weekday()+1)%7),d.strftime("%A"))
> 
> I use this function in one of my buildsteps like this:
> 
> factory.addStep(DirectoryUpload(slavesrc="..\\dist\\setup",masterdest="/bla/{0}".format(createUploadTargetDirectory())))
> 
> if i type the function into the python-commandline it works as expected 
> but buildbot somehow seems to always get the date from the master when 
> it was restarted the last time (i assume thats when the master.cfg is 
> actually loaded...)

Since master.cfg is just a python script, createUploadTargetDirectory() is
evaluated only once :)

You need to use "WithProperties" helper
	http://buildbot.net/buildbot/docs/latest/manual/cfg-properties.html#withproperties

In your case it'll be something like this
	slavesrc=WithProperties("/bla/%(dir)s", dir=createUploadTargetDirectory)

You should pass callable to it, so there should be no "()" when passing
createUploadTargetDirectory. Also IIRC you'll need to change signature of
your createUploadTargetDirectory() function. It should accept one
parameter -- map of exisitng build properties.

-- 
WBR, Dmitry
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 836 bytes
Desc: Digital signature
URL: <http://buildbot.net/pipermail/devel/attachments/20120723/a34642c9/attachment.bin>


More information about the devel mailing list