Issue
In Java, if I want to associated one value with an other I would simply do the following:
static final Map<String, String> VALUES_BY_NAME;
static {
final Map<String, String> valuesByName = new HashMap<>();
valuesByName.put("fruit", "apple");
valuesByName.put("drink", "Coke");
VALUES_BY_NAME = Collections.unmodifiableMap(valuesByName);
}
And call this Hashmap using the following to return apple for example:
VALUES_BY_NAME.get("fruit")
Is there something similar with groovy for Jenkins?
Solution
In Groovy you could do
def myMap = [fruit: 'apple', drink: 'coke'].asUnmodifiable()
Answered By - Reimeus