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
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")
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
writeFile file: 'input', text: someText
sh 'loadStuff.sh < input'
Probably requires some API changes in durable-task.