The "replaceMacro" method in core/src/main/java/hudson/Util.java doesn't work for Windows vairables.
I installed the TestSwarm plugin from https://github.com/appendto/jenkins-testswarm. However, the environment vairables that I set in the plugin are not replace correctly. For example, I tried to use %GIT_COMMIT%, or ${GIT_COMMIT}. Either works. The Jenkin-Testswarm plugin correctly called the Util.replaceMacro method in Jenkins to the proper field, but the environment variables are not replaced.
It seems the regex in the Util is not Windows friendly. If I change the code to the following, it works fine.
Line 140: private static final Pattern VARIABLE = Pattern.compile("\\$%([A-Za-z0-9_]+|
)\\$%)");
...
Line 169: String key = m.group(1);
I have a folk and the changes to it. I'm not an expert on the other platform, can someone check if this works for both Windows and other platforms?
https://github.com/xusun/jenkins/commit/b8dee2c710637e718290f93c31d3854099d2d157#comments
Thanks,
Xun
- is duplicated by
-
JENKINS-11447 Environment variable replacement issue on WINDOWS
- Resolved
-
JENKINS-11448 Environment variable replacement on WINDOWS
- Resolved
-
JENKINS-11449 Environment variable on WINDOWS
- Resolved
-
JENKINS-11450 Environment variable replacement issue on WINDOWS
- Resolved
-
JENKINS-11451 Environment variable replacement issue on WINDOWS
- Resolved