I would like to send an email in the following situations:
- every time a run is failing, and
- every time a run is not failing nor aborted, and the last not-aborted run was not failing (ie. ignoring aborted runs, status changed from failing to something else).
So far I know I can write a post section with a failure condition, like:
pipeline {
[…]
post {
failure {
emailext(
to: 'email@company.com', // testing
subject: "Status: ${currentBuild.result?:'SUCCESS'} - Job \'${env.JOB_NAME}:${env.BUILD_NUMBER}\'",
body: """
<p>EXECUTED: Job <b>\'${env.JOB_NAME}:${env.BUILD_NUMBER}\'</b></p>
<p>View console output at "<a href="${env.BUILD_URL}"> ${env.JOB_NAME}:${env.BUILD_NUMBER}</a>"</p>"""
)
}
}
}
and this handles the first part. But none of the other conditions available in the post
section seem to match my intents: the only conditions that consider the past are changed
, fixed
and regression
, but the first is too generic, fixed
requires the run to be successful (and I also want unstable), and regression
obviously goes in the wrong direction.
How can I do that?