How to reference the variable inside the map . When I do this I only get literal string dcihub_sonar_binaries, while I expect the else rule to result to value of dcihub_sonar_binaries.
dcihub_sonar_binaries = '$WORKSPACE/tenants/dcihub/ui.apps/target/,$WORKSPACE/tenants/dcihub/ui.config/target/,$WORKSPACE/tenants/dcihub/ui.content/target/'
def CODEBASE = "dcihub"
def SonarValues = [:]
if (CODEBASE == "platform") {
SonarValues = ["platform": [platform_sonar_exclusion, platform_sonar_binaries]]
} else {
SonarValues.put(CODEBASE, "${CODEBASE}_sonar_binaries")
}
return SonarValues
}
When I print it. That is the ouput.
dcihub_sonar_binaries
Expected output :
'$WORKSPACE/tenants/dcihub/ui.apps/target/,$WORKSPACE/tenants/dcihub/ui.config/target/,$WORKSPACE/tenants/dcihub/ui.content/target/'
I don't see how/where variable is declared.
If it's a local variable inside function/method then no way to reference it - think about storing all required values in map.
If it's a script/object variable/property then this should work:
Instead of
thisthere could be any object where the variable/property is declared.For example this script prints
Hello world!But this fails because hello_world will be a part of hidden
run()function: