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

CPS Groovy collection.find() returns Boolean

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Duplicate
    • Icon: Major Major
    • pipeline
    • None
    • Workflow 1.1 and Jenkins 1.596

      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.

            kohsuke Kohsuke Kawaguchi
            kbaltrinic Kenneth Baltrinic
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: