From 618705f6175af25fcfa04a979af44b8ed7511d20 Mon Sep 17 00:00:00 2001 From: quicksilver Date: Wed, 10 Jul 2019 17:14:28 +0800 Subject: [PATCH] add email notify function Former-commit-id: 2c4a16473de125cd19c6c440d98171e190786179 --- ci/jenkinsfile/notify.groovy | 15 +++++++++++++++ ci/main_jenkinsfile | 6 ++++++ 2 files changed, 21 insertions(+) create mode 100644 ci/jenkinsfile/notify.groovy diff --git a/ci/jenkinsfile/notify.groovy b/ci/jenkinsfile/notify.groovy new file mode 100644 index 00000000..0a257b8c --- /dev/null +++ b/ci/jenkinsfile/notify.groovy @@ -0,0 +1,15 @@ +def notify() { + if (!currentBuild.resultIsBetterOrEqualTo('SUCCESS')) { + // Send an email only if the build status has changed from green/unstable to red + emailext subject: '$DEFAULT_SUBJECT', + body: '$DEFAULT_CONTENT', + recipientProviders: [ + [$class: 'DevelopersRecipientProvider'], + [$class: 'RequesterRecipientProvider'] + ], + replyTo: '$DEFAULT_REPLYTO', + to: '$DEFAULT_RECIPIENTS' + } +} +return this + diff --git a/ci/main_jenkinsfile b/ci/main_jenkinsfile index c144c466..5c0fde58 100644 --- a/ci/main_jenkinsfile +++ b/ci/main_jenkinsfile @@ -232,6 +232,12 @@ spec: } post { + always { + script { + def notify = load "${env.WORKSPACE}/ci/jenkinsfile/notify.groovy" + notify.notify() + } + } success { script { updateGitlabCommitStatus name: 'CI/CD', state: 'success' -- GitLab