Fix JENKINS-18014

Changed the way that macros are escaped to using something similar to Groovy with two $'s. This required actually looking for the items that matched with two $'s and then handling that case special.