Hi,
It took me a while to find it but it looks like this is the approach
which is also documented ...
... you can find the relating documentation when you use the "Snippet Generator"
looking for the entry "catchError" and then clicking one the question mark.
The final implementation of course depends on your needs. If you wanna stop
the pipeline but doing the cleanup then next example is probably one way to go.
But you also could do a kind of cleanup and proceed with next stage when this
is possible in your case.
Regards,
Thomas
node {
try {
stage "One"
sh "rm /tmp/file_does_not_exist"
} catch (all) {
// doing some cleanup for stage one
throw new Exception("Stage One failed!")
}
try {
stage "Two"
echo "hello world!"
} catch (all) {
// doing some cleanup for stage two
throw new Exception("Stage Two failed!")
}
}