diff --git a/src/eo/Utils.groovy b/src/eo/Utils.groovy index 20644c6..c14eabe 100644 --- a/src/eo/Utils.groovy +++ b/src/eo/Utils.groovy @@ -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