From 8a5076796e2519f543618a4736c57ca34903a0a3 Mon Sep 17 00:00:00 2001 From: "Dustin J. Mitchell" Date: Sat, 26 Mar 2011 11:55:45 -0500 Subject: [PATCH] SetPropertiesFromEnv folds to uppercase for Windows slaves 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. --- master/buildbot/steps/slave.py | 22 +++++++++++++++++----- master/docs/cfg-buildsteps.texinfo | 8 ++++++++ 2 files changed, 25 insertions(+), 5 deletions(-) diff --git a/master/buildbot/steps/slave.py b/master/buildbot/steps/slave.py index fb17a72097f..bfe62430a36 100644 --- a/master/buildbot/steps/slave.py +++ b/master/buildbot/steps/slave.py @@ -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): diff --git a/master/docs/cfg-buildsteps.texinfo b/master/docs/cfg-buildsteps.texinfo index ca9f6d6bf14..cb037e9ce12 100644 --- a/master/docs/cfg-buildsteps.texinfo +++ b/master/docs/cfg-buildsteps.texinfo @@ -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