|
@@ -1,5 +1,7 @@
|
|
|
#!groovy
|
|
|
|
|
|
+def statusHasChanged = false
|
|
|
+
|
|
|
pipeline
|
|
|
{
|
|
|
agent none
|
|
@@ -63,4 +65,44 @@ pipeline
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
+ post
|
|
|
+ {
|
|
|
+ // hooks are called in order: always, changed, aborted, failure, success, unstable
|
|
|
+ changed
|
|
|
+ {
|
|
|
+ echo "Build status has changed."
|
|
|
+ script
|
|
|
+ {
|
|
|
+
|
|
|
+ statusHasChanged = true
|
|
|
+ }
|
|
|
+ }
|
|
|
+ success
|
|
|
+ {
|
|
|
+ echo "Build success."
|
|
|
+ // email when changed to success
|
|
|
+ script
|
|
|
+ {
|
|
|
+ if (statusHasChanged)
|
|
|
+ {
|
|
|
+ emailext(body: '${DEFAULT_CONTENT}',
|
|
|
+ subject: '${DEFAULT_SUBJECT}',
|
|
|
+ replyTo: '$DEFAULT_REPLYTO',
|
|
|
+ to: '$DEFAULT_RECIPIENTS',
|
|
|
+ recipientProviders: [[$class: 'CulpritsRecipientProvider'],[$class: 'RequesterRecipientProvider']])
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ failure
|
|
|
+ {
|
|
|
+ echo "Build failure."
|
|
|
+ // always email on failure
|
|
|
+ emailext(body: '${DEFAULT_CONTENT}',
|
|
|
+ subject: '${DEFAULT_SUBJECT}',
|
|
|
+ replyTo: '$DEFAULT_REPLYTO',
|
|
|
+ to: '$DEFAULT_RECIPIENTS',
|
|
|
+ recipientProviders: [[$class: 'CulpritsRecipientProvider'],[$class: 'RequesterRecipientProvider']])
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|