Skip to content

Commit aa41a7e

Browse files
changing variable substitution code to look for upper-case environment variable definition on Windows (#1330)
1 parent 963586d commit aa41a7e

File tree

1 file changed

+13
-2
lines changed

1 file changed

+13
-2
lines changed

core/src/main/python/wlsdeploy/util/variables.py

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
import re
77

88
from java.lang import Boolean
9+
from java.lang import System
910
from java.io import BufferedReader
1011
from java.io import File
1112
from java.io import FileOutputStream
@@ -276,13 +277,23 @@ def _substitute(text, variables, model_context, error_info, attribute_name=None)
276277
# check environment variables before @@FILE:/dir/@@ENV:name@@.txt@@
277278
matches = _environment_pattern.findall(text)
278279
for token, key in matches:
279-
if str_helper.to_string(key) not in os.environ:
280+
#
281+
# On Windows, environment variables are not case sensitive. On Windows 11 anyway,
282+
# setting an environment variable using a name with lower-case letters will always
283+
# result in an environment variable name in all upper-case.
284+
#
285+
env_var_name = str_helper.to_string(key)
286+
is_windows = System.getProperty('os.name').startswith('Windows')
287+
if is_windows and env_var_name not in os.environ and env_var_name.upper() in os.environ:
288+
env_var_name = env_var_name.upper()
289+
290+
if env_var_name not in os.environ:
280291
allow_unresolved = validation_config.allow_unresolved_environment_tokens()
281292
_report_token_issue('WLSDPLY-01737', method_name, allow_unresolved, key)
282293
_increment_error_count(error_info, allow_unresolved)
283294
problem_found = True
284295
continue
285-
value = os.environ.get(str_helper.to_string(key))
296+
value = os.environ.get(env_var_name)
286297
text = text.replace(token, value)
287298

288299
# check secret variables before @@FILE:/dir/@@SECRET:name:key@@.txt@@

0 commit comments

Comments
 (0)