[Buildbot-devel] Global Environment
Dustin J. Mitchell
dustin at zmanda.com
Thu Dec 11 18:50:57 UTC 2008
On Thu, Dec 11, 2008 at 1:35 PM, Razvan Lupusoru
<lupusoru at cse.ohio-state.edu> wrote:
> compileAndBuildFactory.addStep(ShellCommand(description='Checking
> environment', command=["/bin/env"], env={'INSTALL_PATH':
> '/srv/export/testing/$NOWINSTALLPATH/`svnversion`'}))
>
> There are four problems with this solution:
> 1) I cannot add an environment variable without explicitly running a command
> 2) The INSTALL_PATH variable is not existent for the rest of the steps
Even if the variable assignment worked as you'd like, it would only
set the environment variable for that invocation of env, which, of
course, terminates immediately. That value would not be present for
the next step.
> 3) The $NOWINSTALLPATH variable is treated as a string instead of
> actually using a previously declared variable
> 4) `svnversion` is also treated as a string and does not run as a command
Yep - buildbot just puts those strings into the environment, rather
than invoking the shell on them.
> Ideas on how I can fix any of these problems?
Run each of your steps that need this environment variable as strings
that are passed to the shell, and set the variable at that point.
compileAndBuildFactory.addStep(ShellCommand(command="""
INSTALL_PATH=/srv/export/testing/$NOWINSTALLPATH/`svnversion`
/bin/env
/do/my/thing
"""))
If this would produce a lot of code duplication, you can use a
SetProperty step to get the value once, and then substitute it into
later steps:
compileAndBuildFactory.addStep(SetProperty(property="install_path",
command="""
echo /srv/export/testing/$NOWINSTALLPATH/`svnversion`
"""))
compileAndBuildFactory.addStep(ShellCommand(
command=WithProperties("""
INSTALL_PATH="%(install_path)s"
/bin/env
/do/my/thing
""")))
Dustin
--
Storage Software Engineer
http://www.zmanda.com
More information about the devel
mailing list