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

Pipeline plugin groovy interpreter does not interpret splitEachLine() for all lines

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Duplicate
    • Icon: Minor Minor
    • pipeline
    • Unix + Windows, Jenkins 2.8

      Enter the following pipe

      stage "NOK"
          "A.AA\nB.BB\n".splitEachLine(/\./) {
              line -> println "${line[0]} -> ${line[1]}"
          }
      
      stage "OK"
          "A.AA\nB.BB\n".split(/\n/).each {
              line = it.split(/\./)
              println "${line[0]} -> ${line[1]}"
          }
      

      and disable the sandbox. When you run the pipeline you will see

      [Pipeline] stage (NOK)
      Entering stage NOK
      Proceeding
      [Pipeline] echo
      A -> AA
      [Pipeline] stage (OK)
      Entering stage OK
      Proceeding
      [Pipeline] echo
      A -> AA
      [Pipeline] echo
      B -> BB
      [Pipeline] End of Pipeline
      Finished: SUCCESS
      

      You see that the splitEachLine() is only processing the first line (NOK-stage). I would expect the same result as in the OK-stage.

            Unassigned Unassigned
            andreasschrell Andreas Schrell
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved: