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
At the moment you have to use this procedure with a try
-catch
to get a post-build action.
But in the future this step is planned (actually it is in review). You can read the blog post for further information (see the declarative pipeline part). See also the the Jenkins Jira ticket and the pull request.
The Jenkins declarative pipeline now has the post
section that will run steps conditionally at the end of each build. See the docs for more information.
post {
always {
sh 'echo "This will always run"'
}
success {
sh 'echo "This will run only if successful"'
}
failure {
sh 'echo "This will run only if failed"'
}
unstable {
sh 'echo "This will run only if the run was marked as unstable"'
}
changed {
sh 'echo "This will run only if the state of the Pipeline has changed"'
sh 'echo "For example, the Pipeline was previously failing but is now successful"'
sh 'echo "... or the other way around :)"'
}
}