We are trying to iterate over Map , but without any success. We reduced our problem to this minimal example:
def map = [ 'monday': 'mon', 'tuesday': 'tue', ]
If we try to iterate with:
map.each{ k, v -> println "${k}:${v}" }
Only the first entry is monday:mon
The alternatives that we know of are not even able to enter the cycle:
for (e in map) { println "key = ${e.key}, value = ${e.value}" }
or
for (Map.Entry<String, String> e: map.entrySet()) { println "key = ${e.key}, value = ${e.value}" }
Failed, both indicated only java.io.NotSerializableException: java.util.LinkedHashMap$Entry exception java.io.NotSerializableException: java.util.LinkedHashMap$Entry . (which may be due to an exception that occurs when raising a "real" exception, not allowing us to find out what happened).
We use the latest stable jenkins (2.19.1) with all the plugins that are relevant to date (2016/10/20).
Is there a solution for iterating over elements in a Map in the Jenkins Groovy script pipeline?
dictionary jenkins groovy jenkins-pipeline
Ad n
source share