jenkinsci / jenkinsci/workflow-cps-plugin
[JENKINS-48308] Translate StringGroovyMethods.eachLine
- Dominant language
- Java
- Stars
- 186
- Forks
- 213
- Avg merge
- 12h 12m
- Merged PRs (30d)
- 8
Description
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.
---
Originally reported by hifi, imported from: Translate StringGroovyMethods.eachLine
Raw content of original issue
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.
Contributor guide
Research direction
Reproduce the reported pipeline using sh with returnStdout and StringGroovyMethods.eachLine, then inspect the workflow-cps-plugin handling of that call. Compare it with the working execute().text example and verify that multi-line shell output is processed line by line when the issue is fixed.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- groovy
- Domain
- ci-cd
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100