-
Improvement
-
Resolution: Fixed
-
Major
Currently sh has no meaningful return value, and throws an exception if the exit status is not zero. Would be nice to have an option to have it return the exit code (zero or not) as an integer value:
def r = sh script: 'someCommand', returnStatus: true
Current workaround:
sh 'someCommand; echo $? > status' def r = readFile('status').trim()
Or to have it return its standard output (akin to shell backticks):
def lines = sh(script: 'dumpStuff.sh', returnStdout: true).split("\r?\n")
Workaround:
sh 'dumpStuff.sh > result' def lines = readFile('result').split("\r?\n")
Or to have it take something on standard input:
sh script: 'loadStuff.sh', stdin: someText
Workaround:
writeFile file: 'input', text: someText sh 'loadStuff.sh < input'
Probably requires some API changes in durable-task.
- is duplicated by
-
JENKINS-34331 get shell to expose a value
- Resolved
-
JENKINS-26812 Storing the shell script execution output in workflow
- Resolved
-
JENKINS-28302 Workflow steps should expose console output to script somehow
- Resolved
-
JENKINS-33173 Improve how to get output of sh execution
- Resolved
- is related to
-
JENKINS-29877 failure when incorrect shell is configured is not clear enough to diagnose root cause.
- Open
-
JENKINS-27152 Store sh control files outside of workspace
- Resolved
-
JENKINS-44930 Allow sh to return exit status, stdout and stderr all at once
- Open
- links to