Hi,
I'm using this code:
node(...) {
try {
...add stages here...
} catch(Exception e) {
currentBuild.result = 'FAILURE' // Let the post step know that
the build failed with an error.
throw e
} finally {
builder.post(currentBuild)
}
} // node
The code for post() looks like so:
def post(def currentBuild) {
String currentResult = currentBuild.result ?: 'SUCCESS'
echo "post ${currentResult}"
try {
postAlways(currentBuild)
} catch(Exception e) {
def converted = toString(e)
echo "postAlways failed (ignored):\n${converted}"
}
if (currentResult == 'SUCCESS') {
success(currentBuild)
} else {
failed(currentBuild, currentResult)
}
}
Hope this helps,
Aaron Digulla
On Thursday, February 28, 2019 at 9:41:50 PM UTC+1, Faad Sayaou wrote:
>
> Hi everyone
> I am using the extended email plugin for notification when the build fails
> by using try catch. I will also like to send email when the build is
> unstable.
>
--
You received this message because you are subscribed to the Google Groups
"Jenkins Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/jenkinsci-users/eda1618f-94e8-4efa-9875-3d48e715a34f%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.