if i define a groovy variable
def x = \"anish$\"
it will throw me error, the fix is
def x = \"anish\\$\"
It might be a cheap method, but the following works for me.
def x = "anish" + '$'