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

CPS Groovy collection.find() returns Boolean

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Resolved (View Workflow)
    • Priority: Major
    • Resolution: Duplicate
    • Component/s: pipeline
    • Labels:
      None
    • Environment:
      Workflow 1.1 and Jenkins 1.596
    • Similar Issues:

      Description

      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.

        Attachments

          Issue Links

            Activity

            Hide
            akbertram Alexander Bertram added a comment -

            Think I beat you to it by a few hours
            https://issues.jenkins-ci.org/browse/JENKINS-26300

            Show
            akbertram Alexander Bertram added a comment - Think I beat you to it by a few hours https://issues.jenkins-ci.org/browse/JENKINS-26300
            Hide
            kbaltrinic Kenneth Baltrinic added a comment -

            Well maybe. I actually first reported the problem in the forum, just to make sure I was seeing straight. https://groups.google.com/forum/#!topic/jenkinsci-users/IoiKJ78OMG8

            Show
            kbaltrinic Kenneth Baltrinic added a comment - Well maybe. I actually first reported the problem in the forum, just to make sure I was seeing straight. https://groups.google.com/forum/#!topic/jenkinsci-users/IoiKJ78OMG8
            Hide
            jglick Jesse Glick added a comment -

            Probably the same code flaw as JENKINS-26300 reports.

            Show
            jglick Jesse Glick added a comment - Probably the same code flaw as JENKINS-26300 reports.

              People

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

                Dates

                • Created:
                  Updated:
                  Resolved: