소스 검색

contrib: send email on failure and on status change

Nathalie Furmento 7 년 전
부모
커밋
00ec139f9f
1개의 변경된 파일42개의 추가작업 그리고 0개의 파일을 삭제
  1. 42 0
      contrib/ci.inria.fr/Jenkinsfile-basic

+ 42 - 0
contrib/ci.inria.fr/Jenkinsfile-basic

@@ -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']])
+		}
+	}
 }