You can use waitForProcessOutputone that accepts two appendables ( docs here )
def process = "ls -l".execute()
def (output, error) = new StringWriter().with { o ->
new StringWriter().with { e ->
process.waitForProcessOutput( o, e )
[ o, e ]*.toString()
}
}
println "OUT: $output"
println "ERR: $error"
source
share