Trying to append a string variable to Global variable

@Russ_Thomas, I saw your solution for similar thing here link

how can I create globalvariable for map type at runtime. Currently I am using the following script to create globalvariable for string

static void addGlobalVariable(String name, def value) {
GroovyShell shell1 = new GroovyShell()
MetaClass mc = shell1.evaluate(“internal.GlobalVariable”).metaClass
String getterName = “get” + name.capitalize()
String setterName = “set” + name.capitalize()
mc.‘static’.“$getterName” = { → return value }
mc.‘static’.“$setterName” = { newValue → value = newValue }
mc.‘static’.“$name” = value
}