-
Bug
-
Resolution: Fixed
-
Minor
-
jenkins 1.50.2, all workflow plugin versions
-
-
workflow-cps 2.66, script-security 1.57
In Pipeline, doing params.get as recommended by jglick in:
https://github.com/jenkinsci/workflow-cps-plugin/commit/7c29a4d24f575e61d80a7aed7b48d6ba5750a5a6
doesn't work because Groovy Map.get(Object, Object) actually tries to modify the map; whereas the params Map is an UnmodifiableMap.
When I tried this code, I got the exception:
java.lang.UnsupportedOperationException at java.util.Collections$UnmodifiableMap.put(Collections.java:1457) at org.codehaus.groovy.runtime.DefaultGroovyMethods.get(DefaultGroovyMethods.java:7080)
I recommend instead Map.getOrDefault, which does not try to modify the Map. Pull request incoming for an update to documentation.