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

          Hide
          daniel_c_686 Daniel Carrington added a comment -

          https://github.com/jenkinsci/workflow-cps-plugin/pull/275
          Minor documentation update fixing the words in the help.jelly to recommend Map.getOrDefault instead.

          Show
          daniel_c_686 Daniel Carrington added a comment - https://github.com/jenkinsci/workflow-cps-plugin/pull/275 Minor documentation update fixing the words in the help.jelly to recommend Map.getOrDefault instead.
          Hide
          dnusbaum Devin Nusbaum added a comment -

          The updated documentation was just released in version 2.66 of Pipeline: Groovy Plugin. I will try to release Script Security shortly to get the update that adds the new recommendation to the default whitelist.

          Show
          dnusbaum Devin Nusbaum added a comment - The updated documentation was just released in version 2.66 of Pipeline: Groovy Plugin. I will try to release Script Security shortly to get the update that adds the new recommendation to the default whitelist.
          Hide
          dnusbaum Devin Nusbaum added a comment -

          Map.getOrDefault(Object, Object) is now whitelisted by default in Script Security 1.57.

          Show
          dnusbaum Devin Nusbaum added a comment - Map.getOrDefault(Object, Object) is now whitelisted by default in Script Security 1.57.

            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: