Skip to content
Permalink
Browse files
Fix JENKINS-13157
  • Loading branch information
gboissinot committed Mar 21, 2012
1 parent 8c84404 commit 7cad840a6f897438c855d10b556e142ef8c465a2
Showing with 8 additions and 3 deletions.
  1. +8 −3 src/main/java/org/jenkinsci/plugins/envinject/service/EnvInjectEnvVars.java
@@ -166,7 +166,8 @@ public void resolveVars(Map<String, String> variables, Map<String, String> env)

//Resolve variables against env
for (Map.Entry<String, String> entry : variables.entrySet()) {
entry.setValue(Util.replaceMacro(entry.getValue(), env));
String value = Util.replaceMacro(entry.getValue(), env);
entry.setValue(value);
}

//Resolve variables against variables itself
@@ -193,7 +194,7 @@ public void resolveVars(Map<String, String> variables, Map<String, String> env)
Map<String, String> result = new HashMap<String, String>();
for (Map.Entry<String, String> entry : envVars.entrySet()) {
if (!isUnresolvedVar(entry.getValue())) {
result.put(entry.getKey(), entry.getValue());
result.put(entry.getKey(), removeEscapeDollar(entry.getValue()));
} else {
logger.info(String.format("Unset unresolved '%s' variable.", entry.getKey()));
}
@@ -202,7 +203,11 @@ public void resolveVars(Map<String, String> variables, Map<String, String> env)
}

private boolean isUnresolvedVar(String value) {
return value != null && value.contains("$");
return value != null && value.contains("$") && !value.contains("\\$");
}

private String removeEscapeDollar(String value) {
return value.replace("\\$", "$");
}

}

0 comments on commit 7cad840

Please sign in to comment.