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
This is working well on my Jenkins (current ver 2.164.2 and emailext) with declarative pipeline:
pipeline {
...
environment {
EMAIL_TO = 'someone@host.com'
}
post {
failure {
emailext body: 'Check console output at $BUILD_URL to view the results. \n\n ${CHANGES} \n\n -------------------------------------------------- \n${BUILD_LOG, maxLines=100, escapeHtml=false}',
to: "${EMAIL_TO}",
subject: 'Build failed in Jenkins: $PROJECT_NAME - #$BUILD_NUMBER'
}
unstable {
emailext body: 'Check console output at $BUILD_URL to view the results. \n\n ${CHANGES} \n\n -------------------------------------------------- \n${BUILD_LOG, maxLines=100, escapeHtml=false}',
to: "${EMAIL_TO}",
subject: 'Unstable build in Jenkins: $PROJECT_NAME - #$BUILD_NUMBER'
}
changed {
emailext body: 'Check console output at $BUILD_URL to view the results.',
to: "${EMAIL_TO}",
subject: 'Jenkins build is back to normal: $PROJECT_NAME - #$BUILD_NUMBER'
}
}
}
You can control email for failed build or changed status. Also I've put build log to the email body