[Buildbot-devel] Set properties from output of shell commands

Dustin J. Mitchell dustin at zmanda.com
Wed Apr 23 17:06:25 UTC 2008


I've proposed a patch to add a SetProperty step, at
http://buildbot.net/trac/ticket/232.  Please comment the ticket if
this is useful to you, or if it's missing functionality that would be
useful to you.

Here are the docs:

This buildstep is similar to ShellCommand, except that it captures the
output of the command into a property. It is usually used like this:

     f.addStep(SetProperty(command="uname -a", property="uname"))
This runs uname -a and captures the output, stripped of leading and
trailing whitespace, in the property "uname". To avoid stripping, add
strip=False. The property argument can be specified as a
WithProperties object.

The more advanced usage allows you to specify a function to extract
properties from the command output. Here you can use regular
expressions, string interpolation, or whatever you would like. The
function is called with three arguments: the exit status of the
command, its standard output, and its standard error. It should return
a dictionary containing all new properties.

     def glob2list(rc, stdout, stderr):
         jpgs = [ l.strip() for l in stdout.split('\n') ]
         return { 'jpgs' : jpgs }
     f.addStep(SetProperty(command="ls -1 *.jpg", extract_fn=glob2list))

Dustin

-- 
Storage Software Engineer
http://www.zmanda.com




More information about the devel mailing list