From 82263742d0d5a2f213b822bf65ed3f9d32dac7a7 Mon Sep 17 00:00:00 2001 From: Sean Talts Date: Tue, 29 May 2018 15:25:38 -0400 Subject: [PATCH 1/2] Don't let email excpetions clutter the UI --- Jenkinsfile | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index 4bce42b1d65..98db745b918 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -15,12 +15,18 @@ def setup(Boolean failOnError = true) { } def mailBuildResults(String label, additionalEmails='') { - emailext ( - subject: "[StanJenkins] ${label}: Job '${env.JOB_NAME} [${env.BUILD_NUMBER}]'", - body: """${label}: Job '${env.JOB_NAME} [${env.BUILD_NUMBER}]': Check console output at ${env.BUILD_URL}""", - recipientProviders: [[$class: 'RequesterRecipientProvider']], - to: "${env.CHANGE_AUTHOR_EMAIL}, ${additionalEmails}" - ) + try { + emailext ( + subject: "[StanJenkins] ${label}: Job '${env.JOB_NAME} [${env.BUILD_NUMBER}]'", + body: """${label}: Job '${env.JOB_NAME} [${env.BUILD_NUMBER}]': Check console output at ${env.BUILD_URL}""", + recipientProviders: [[$class: 'RequesterRecipientProvider']], + to: "${env.CHANGE_AUTHOR_EMAIL}, ${additionalEmails}" + ) + } catch (all) { + println "Encountered the following exception sending email; please ignore:" + println all + println "End ignoreable email-sending exception." + } } def runTests(String testPath) { From cf3f5697627c86de6ee84ff3a367fd1505a83995 Mon Sep 17 00:00:00 2001 From: Sean Talts Date: Wed, 30 May 2018 15:07:28 -0400 Subject: [PATCH 2/2] wrap try catch in script tag for effect --- Jenkinsfile | 24 +++++++++++++----------- 1 file changed, 13 insertions(+), 11 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index 98db745b918..1b5ebddc7ab 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -15,17 +15,19 @@ def setup(Boolean failOnError = true) { } def mailBuildResults(String label, additionalEmails='') { - try { - emailext ( - subject: "[StanJenkins] ${label}: Job '${env.JOB_NAME} [${env.BUILD_NUMBER}]'", - body: """${label}: Job '${env.JOB_NAME} [${env.BUILD_NUMBER}]': Check console output at ${env.BUILD_URL}""", - recipientProviders: [[$class: 'RequesterRecipientProvider']], - to: "${env.CHANGE_AUTHOR_EMAIL}, ${additionalEmails}" - ) - } catch (all) { - println "Encountered the following exception sending email; please ignore:" - println all - println "End ignoreable email-sending exception." + script { + try { + emailext ( + subject: "[StanJenkins] ${label}: Job '${env.JOB_NAME} [${env.BUILD_NUMBER}]'", + body: """${label}: Job '${env.JOB_NAME} [${env.BUILD_NUMBER}]': Check console output at ${env.BUILD_URL}""", + recipientProviders: [[$class: 'RequesterRecipientProvider']], + to: "${env.CHANGE_AUTHOR_EMAIL}, ${additionalEmails}" + ) + } catch (all) { + println "Encountered the following exception sending email; please ignore:" + println all + println "End ignoreable email-sending exception." + } } }