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

          daniel_c_686 Daniel Carrington created issue -
          daniel_c_686 Daniel Carrington made changes -
          Field Original Value New Value
          Component/s workflow-cps-plugin [ 21713 ]
          Component/s workflow-job-plugin [ 21716 ]
          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.
          daniel_c_686 Daniel Carrington made changes -
          Status Open [ 1 ] In Progress [ 3 ]
          jglick Jesse Glick made changes -
          Assignee Jesse Glick [ jglick ] Daniel Carrington [ daniel_c_686 ]
          jglick Jesse Glick made changes -
          Status In Progress [ 3 ] In Review [ 10005 ]
          jglick Jesse Glick made changes -
          Labels documentation
          dnusbaum Devin Nusbaum made changes -
          Status In Review [ 10005 ] Fixed but Unreleased [ 10203 ]
          Resolution Fixed [ 1 ]
          dnusbaum Devin Nusbaum made changes -
          Remote Link This issue links to "jenkinsci/workflow-cps-plugin#275 (Web Link)" [ 22528 ]
          dnusbaum Devin Nusbaum made changes -
          Remote Link This issue links to "jenkinsci/script-security-plugin#240 (Web Link)" [ 22529 ]
          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.
          dnusbaum Devin Nusbaum made changes -
          Status Fixed but Unreleased [ 10203 ] Resolved [ 5 ]
          Released As workflow-cps 2.66
          dnusbaum Devin Nusbaum made changes -
          Released As workflow-cps 2.66 workflow-cps 2.66, script-security 1.57
          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: