[Buildbot-devel] how to use environment variable in build step
William Siegrist
wsiegrist at apple.com
Thu Nov 11 14:59:45 UTC 2010
On Nov 11, 2010, at 3: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?
If you write a custom ShellCommand-based class yourself, you can get environment variables from os.environ.
http://docs.python.org/library/os.html
.. although I personally would use a SetProperty to add those variables to build properties so they are recorded along with the build, and then use WithProperties in the ShellCommand.
-Bill
More information about the devel
mailing list