CPS Groovy collection.find() returns Boolean

This issue is archived. You can view it, but you can't modify it. Learn more

XMLWordPrintable

      To demonstrate the issue createa new workflow job with the following script:

      def str="1:one|2:two|3:three"
      def i = "2"
      def opts = str.split(/\|/)
      def opt = opts.find { o -> o.contains("${i}:") }
      echo "len: ${opts.length}"
      echo "opt: ${opt}"
      

      The output of which is

      Started by user anonymous
      Running: Print Message
      len: 3
      Running: Print Message
      opt: false
      Running: End of Workflow
      Finished: SUCCESS

      Note the value returned for opt. It appears that the current behavior of find in cps is to return the result of the closure for the first element in the collection.

            Assignee:
            Kohsuke Kawaguchi
            Reporter:
            Kenneth Baltrinic
            Archiver:
            Jenkins Service Account

              Created:
              Updated:
              Resolved:
              Archived: