Skip to content
Browse files
[FIXED JENKINS-16660] Allow variable names with dots in bracketed ref…

Given these <variable,value> mappings: <A,a> and <A.B,a-b>, $A.B would
evaluate to $a.B, as it currently does, and ${A.B} to a-b instead of the
current ${A.B}.

Existing ${A.B}-like references will break (not evaluate to ${A.B}) if
there actually is an A.B variable defined, which I think is very

(cherry picked from commit 3376cf0)
  • Loading branch information
LarryNorth authored and olivergondza committed Sep 13, 2013
1 parent a01c6c5 commit f664639b79d2dea2abdf48816b01f8ccc525a73f
Showing with 7 additions and 2 deletions.
  1. +2 −2 core/src/main/java/hudson/
  2. +5 −0 core/src/test/java/hudson/
@@ -114,9 +114,9 @@ public static <T> List<T> filter( List<?> base, Class<T> type ) {

* Pattern for capturing variables. Either $xyz or ${xyz}, while ignoring "$$"
* Pattern for capturing variables. Either $xyz, ${xyz} or ${a.b} but not $a.b, while ignoring "$$"
private static final Pattern VARIABLE = Pattern.compile("\\$([A-Za-z0-9_]+|\\{[A-Za-z0-9_]+\\}|\\$)");
private static final Pattern VARIABLE = Pattern.compile("\\$([A-Za-z0-9_]+|\\{[A-Za-z0-9_.]+\\}|\\$)");

* Replaces the occurrence of '$key' by <tt>properties.get('key')</tt>.
@@ -49,6 +49,7 @@ public class UtilTest {
public void testReplaceMacro() {
Map<String,String> m = new HashMap<String,String>();
m.put("DOLLAR", "$");
@@ -67,6 +68,10 @@ public void testReplaceMacro() {
assertEquals("asd$${AA}dd", Util.replaceMacro("asd$$$${AA}dd",m));
assertEquals("$", Util.replaceMacro("$$",m));
assertEquals("$$", Util.replaceMacro("$$$$",m));

// dots
assertEquals("a.B", Util.replaceMacro("$A.B", m));
assertEquals("a-b", Util.replaceMacro("${A.B}", m));

// test that more complex scenarios work
assertEquals("/a/B/aa", Util.replaceMacro("/$A/$B/$AA",m));

0 comments on commit f664639

Please sign in to comment.