jenkinsci / jenkinsci/workflow-cps-plugin

[JENKINS-48308] Translate StringGroovyMethods.eachLine

Open
#1,387 1 comment 0 reactions 0 assignees View on GitHub
component:workflow-cps-plugin imported-jira-issue priority:minor resolution:unresolved
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


  • status: Open
  • priority: Minor
  • component(s): workflow-cps-plugin
  • resolution: Unresolved
  • votes: 0
  • watchers: 3
  • imported: 2025-12-07

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

Open the contributing 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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.