add mail_notify method

This commit is contained in:
Emmanuel Cazenave 2018-04-25 10:23:23 +02:00
parent 4e3101748c
commit 5796bb5ae5
1 changed files with 20 additions and 0 deletions

View File

@ -7,4 +7,24 @@ def publish_cobertura_report(report_pattern) {
maxNumberOfBuilds: 0, onlyStable: false, sourceEncoding: 'ASCII', zoomCoverageChart: false])
}
def mail_notify(currentBuild, env, email) {
/* Send mail to 'email' if branch is master
else send mail to the author of last commit
*/
if (currentBuild.result == null) {
// Hack to have the 'jenkins build back to normal' mail sent
currentBuild.result = 'SUCCESS'
}
if (env.BRANCH_NAME == 'master') {
step([$class: 'Mailer', notifyEveryUnstableBuild: true,
recipients: email, sendToIndividuals: true])
} else {
step([$class: 'Mailer',
notifyEveryUnstableBuild: true,
recipients: emailextrecipients([[$class: 'CulpritsRecipientProvider'],
[$class: 'RequesterRecipientProvider']])])
}
}
return this