Groovy script create a string same name as predefined variable and return it

98 views Asked by At

Hi everyone I am trying to run below code in groovy webconsole:

​// Static content examples. These lists can be generated dynamically as an alternative.
List STAGE_ALL = ["aceapp01","aceapp02","aceapp03","acemgt01"]

String allclusters = 'STAGE_ALL'
String ServerType= 'ALL'

if (ServerType == 'ALL') {
  return allclusters
} else {
  return default_item
}

In this when I do return allclusters it gives me STAGE_ALL whereas I want value under STAGE_ALL that is the list which I predefined [aceapp01, aceapp02, aceapp03, acemgt01]. This I get when I return STAGE_ALL list specifically.

0

There are 0 answers