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

Translate StringGroovyMethods.eachLine

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Unresolved
    • Icon: Minor Minor
    • workflow-cps-plugin
    • None

      When I tried to parse Maven output (which is running using sh -step), noticed that groovy code only sees first line of output. Example pipeline:

      node() { 
      def outputLog 
      outputLog = sh(script: "ls -la /", returnStdout: true) 
      println outputLog
      //prints full log
      outputLog.eachLine { line, count -> println "$count: $line" }
      //prints only 1 line 
      outputlog = "ls -la /".execute().text outputlog.eachLine { println it }
      //prints all lines 
      }

      So workaround is to use that Groovy's execute.

            Unassigned Unassigned
            hifi Juho Saarinen
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated: