[Buildbot-devel] Global Environment

Razvan Lupusoru lupusoru at cse.ohio-state.edu
Fri Dec 12 17:30:19 UTC 2008


This explains a lot and it is a very useful guide. However, it seems 
that the SetProperty ability was added as of 0.7.8 and currently I only 
have 0.7.7 on the server. The first suggestion would work but it 
definitely would lead to a lot of code duplication so it seems that I 
need something that is similar to the second solution. Is there a class 
I can add to my own .cfg file that would be able to replace the 
SetProperty functionality?

Thank you,

Razvan Lupusoru

Dustin J. Mitchell wrote:
> 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
>
>   





More information about the devel mailing list