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

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

    Details

    • Similar Issues:
    • Released As:
      workflow-cps 2.66, script-security 1.57

      Description

      In Pipeline, doing params.get as recommended by Jesse Glick 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.

        Attachments

          Activity

            People

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

              Dates

              • Created:
                Updated:
                Resolved: