Skip to content

Commit

Permalink
SetPropertiesFromEnv folds to uppercase for Windows slaves
Browse files Browse the repository at this point in the history
Windows environment variables are case-insensitive but in some displays
are case-preserving.  The step now detects when the slave is win32, and
behaves accordingly on the master side by folding keys to uppercase.
Fixes #1892.
  • Loading branch information
djmitche committed Mar 26, 2011
1 parent 6ece3e5 commit 8a50767
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 5 deletions.
22 changes: 17 additions & 5 deletions master/buildbot/steps/slave.py
Expand Up @@ -36,14 +36,26 @@ def __init__(self, variables, source="SlaveEnvironment", **kwargs):
self.source = source

def start(self):
# on Windows, environment variables are case-insensitive, but we have
# a case-sensitive dictionary in slave_environ. Fortunately, that
# dictionary is also folded to uppercase, so we can simply fold the
# variable names to uppercase to duplicate the case-insensitivity.
fold_to_uppercase = (self.buildslave.slave_system == 'win32')

properties = self.build.getProperties()
environ = self.buildslave.slave_environ
if isinstance(self.variables, str):
self.variables = [self.variables]
for variable in self.variables:
value = environ.get(variable, None)
variables = self.variables
if isinstance(variables, str):
variables = [self.variables]
for variable in variables:
key = variable
if fold_to_uppercase:
key = variable.upper()
value = environ.get(key, None)
if value:
properties.setProperty(variable, value, self.source, runtime=True)
# note that the property is not uppercased
properties.setProperty(variable, value, self.source,
runtime=True)
self.finished(SUCCESS)

class FileExists(BuildStep):
Expand Down
8 changes: 8 additions & 0 deletions master/docs/cfg-buildsteps.texinfo
Expand Up @@ -1989,6 +1989,14 @@ master on connect. These can be copied into Buildbot properties with the
@code{variables} parameter, then simply use the values as properties in a later
step.

Note that on Windows, environment variables are case-insensitive, but Buildbot
property names are case sensitive. The property will be capitalized based on
the variable name you specify, not on the capitalization of the environment
variable name on the slave. If, for example, you use
@code{variables=['PROGRAMFILES']}, the result will be a property named
@code{PROGRAMFILES}, even though the environment variable is displayed as
@code{ProgramFiles} in the Windows GUI.

@example
from buildbot.steps.slave import SetPropertiesFromEnv
from buildbot.steps.shell import Compile
Expand Down

0 comments on commit 8a50767

Please sign in to comment.