• Icon: Bug Bug
    • Resolution: Duplicate
    • Icon: Major Major
    • pipeline

      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
      

          [JENKINS-32451] Collection.find returns boolean

          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.

          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 .

          Jesse Glick added a comment -

          Well known limitation.

          Jesse Glick added a comment - Well known limitation.

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

              Created:
              Updated:
              Resolved: