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

Collection.find returns boolean

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Resolved (View Workflow)
    • Priority: Major
    • Resolution: Duplicate
    • Component/s: pipeline
    • Environment:
    • Similar Issues:

      Description

      I have strange problem with workflow script. My simple code look like:

      def tab = [1, 2, 3, 4, 5]
      def five = tab.find{it==5}
      println five
      

      The output of script is:

      Started by user anonymous
      [Workflow] Allocate node : Start
      Running on master in D:\jenkins\jobs\example_workflow\workspace
      [Workflow] node {
      [Workflow] echo
      false
      [Workflow] } //node
      [Workflow] Allocate node : End
      [Workflow] End of Workflow
      Finished: SUCCESS
      

      Why workflow returns boolean value? When I execute this script without workflow it show correct value:

      5
      

        Attachments

          Issue Links

            Activity

            Hide
            mijay Mitya Kononchuk added a comment - - edited

            find method as many others using closures are not supported in workflow code. You should put such code in NonCPS blocks. See best practices.

            Show
            mijay Mitya Kononchuk added a comment - - edited find method as many others using closures are not supported in workflow code. You should put such code in NonCPS blocks. See best practices .
            Hide
            jglick Jesse Glick added a comment -

            Well known limitation.

            Show
            jglick Jesse Glick added a comment - Well known limitation.

              People

              Assignee:
              jglick Jesse Glick
              Reporter:
              rkuc Rafał Kuć
              Votes:
              0 Vote for this issue
              Watchers:
              4 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved: