How can i add to a jenkins pipeline an old-style post-build task which sends email when the build fails? I cannot find \"Post-build actions\" in the GUI for a pipeline. I know t
to DRY your scripted pipelines you can easily extend Jenkins with your own shared library and define a custom step emailOnError like
def call(Closure action) {
try {
action()
} catch(e){
emailext body: '$DEFAULT_CONTENT',
recipientProviders: [
[$class: 'DevelopersRecipientProvider'],
[$class: 'RequesterRecipientProvider']
],
replyTo: '$DEFAULT_REPLYTO',
subject: '$PROJECT_NAME - Build # $BUILD_NUMBER - ERROR!',
to: '$DEFAULT_RECIPIENTS'
throw err
}
}
then use it like
emailOnError() {
// Do sth
}