Uploaded image for project: 'Jenkins'
  1. Jenkins
  2. JENKINS-56688

pipeline-syntax Global Variables params.get doesn't work

XMLWordPrintable

    • 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.

            daniel_c_686 Daniel Carrington
            daniel_c_686 Daniel Carrington
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: