Groovy executing shell commands

Groovy adds the execute method to String to make executing shells fairly easy; println “ls”.execute().text but if an error happens, then there is no resulting output. Is there an easy way to get both the standard error and standard out? (other than creating a bunch of code to; create two threads to read both inputstreams, … Read more

How do I get the output of a shell command executed using into a variable from Jenkinsfile (groovy)?

I have something like this on a Jenkinsfile (Groovy) and I want to record the stdout and the exit code in a variable in order to use the information later. sh “ls -l” How can I do this, especially as it seems that you cannot really run any kind of groovy code inside the Jenkinsfile? … Read more