[Buildbot-devel] how to use environment variable in build step

Charles Lepple clepple at gmail.com
Thu Nov 11 12:04:23 UTC 2010


On Nov 11, 2010, at 6:50 AM, Hendryk Bockelmann wrote:

> I am using a simple BuildFactory to perform some shell scripts on my  
> build-slave, ie. the master.cfg looks like:
>
> my_fac = factory.BuildFactory()
> my_fac.addStep(shell.ShellCommand(description='run test 1',
>                                   command=["/home/user/scripts/ 
> foo.sh", "--with-option=1"],
>                                   workdir="/tmp/buildbot"))
>
> To be more flexible in my builds, I would like to replace the  
> absolute paths in the ShellCommand and use s.th. like
>
> my_fac = factory.BuildFactory()
> my_fac.addStep(shell.ShellCommand(description='run test 1',
>                                   command=["$HOME/scripts/foo.sh",  
> "--with-option=1"],
>                                   workdir="$WORK"))
>
> where the HOME and WORK environment vars are already setup on each  
> buildslave ... but unfortunately the environment vars do not get  
> expanded when the build runs. So where is my mistake?

The key here:

    http://buildbot.net/buildbot/docs/0.8.2/Using-ShellCommands.html#Using-ShellCommands

is that the environment variables won't get expanded unless you use a  
shell, and passing a list of strings (versus a single string) will not  
invoke a shell. (Regardless of how you specify the command, other  
parameters such as workdir don't undergo shell expansion at all, but  
you could use WithProperties in many cases.)

You might try something like:

    command="cd $WORK && $HOME/scripts/foo.sh --with-option=1"

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://buildbot.net/pipermail/devel/attachments/20101111/7328e80c/attachment.html>


More information about the devel mailing list