You need to wrap your groovy code into a try/catch/finally block and check
the current build result ( I also give you some hint when things are not
yet filled)
try
{
}
catch(any)
{
println('Error occurred during build:');
println(any.toString());
println('Marking build as FAILURE because of this');
currentBuild.result = 'FAILURE'
throw any //rethrow exception to prevent the build from proceeding
}
finally
{
if(!currentBuild.result)
{
currentBuild.result = 'SUCCESS'
println("Current build result is undefined, setting it as
${currentBuild.result}")
}
// send email
emailext body: 'my email body', subject: 'email subject', to:
'[email protected]', replyTo: '[email protected]', mimeType: 'text/html';
}
--
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/dfdf3042-8b26-4f83-b43f-a17b8142a4a3%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.