Reputation: 51
When a build job fails, I want to send an email to the user who started the job.
I use a jenkins buildfile (Pipeline script). The current code is:
post {
success {
doSomething()
}
failure {
step([$class: 'Mailer', notifyEveryUnstableBuild: true, recipients: 'me@foo', sendToIndividuals: true])
}
changed {
step([$class: 'Mailer', notifyEveryUnstableBuild: true, recipients: 'me@foo', sendToIndividuals: true])
}
}
Sending the mail to me@foo "statically" (i.e. putting the address as in the code above) works well. So the Mailer plugin works well, but I cannot figure out how to make a reference to the user that started the job.
I tried out putting s.th. like the following at the recipients list, but it does not work: '${BUILD_USER_EMAIL}', $BUILD_USER_EMAIL
Thank you in advance for any hint to solve this.
Upvotes: 0
Views: 1401
Reputation: 51
We identified the problem by ourselves: the plugin build user vars was not activated correctly. Now it works.
We use the following code:
pipeline {
...
post {
failure {
step([$class: 'Mailer', notifyEveryUnstableBuild: true, recipients: "${BUILD_USER_EMAIL}", sendToIndividuals: true])
}
changed {
step([$class: 'Mailer', notifyEveryUnstableBuild: true, recipients: "${BUILD_USER_EMAIL}", sendToIndividuals: true])
}
}
}
Thank you for your replies.
Upvotes: 0