Re: Pipeline: Sending email on failed and fixed builds

2016-11-15 Thread James Douglas Robinson
found this and it seems to work

https://support.cloudbees.com/hc/en-us/articles/226419147-How-can-I-check-previous-build-status-in-a-Pipeline-Script-

-- 
You received this message because you are subscribed to the Google Groups 
"Jenkins Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to jenkinsci-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/jenkinsci-users/40bd3710-a4c0-4754-bbaa-324d5c7de5df%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Pipeline: Sending email on failed and fixed builds

2016-09-16 Thread Vikrant Verma
Hi Sverre,

Can you share the command which works to send email for build failures and 
build fixed ?

Thanks.

On Thursday, June 23, 2016 at 5:26:13 AM UTC-4, Sverre Moe wrote:
>
> I got Mailer to send success after failed.
> I wish "mail" or "emailext" could support this as those allow to define 
> the subject and body.
>
> torsdag 23. juni 2016 10.58.51 UTC+2 skrev Sverre Moe følgende:
>>
>> Ok
>> We went away from the Mailer because we wanted to minimize the content in 
>> body.
>>
>> I tried with your example, but it did not send out email on success after 
>> failed.
>> } catch (caughtError) {
>> currentBuild.result = "FAILURE"
>> } finally {
>>if (currentBuild.result != "ABORTED") {
>>final def RECIPIENTS = emailextrecipients([
>>[$class: 'DevelopersRecipientProvider'],
>>[$class: 'CulpritsRecipientProvider']
>>])
>>
>>step([$class: 'Mailer', notifyEveryUnstableBuild: true, 
>> sendToIndividuals: true, recipients: RECIPIENTS])
>> }
>>
>> /* Must re-throw exception to propagate error */
>> if (err) {
>> throw err
>> }
>> }
>>
>>
>> Using the following will send out emails on every SUCCESS, regardless of 
>> previous build result.
>> emailext body: CONTENT, subject: SUBJECT, replyTo: 'donot...@company.com 
>> ', recipientProviders: [[$class: 
>> 'CulpritsRecipientProvider'], [$class: 'DevelopersRecipientProvider']]
>>
>> I could use the following to send out email on every failed build, but 
>> will not get sent when build is fixed.
>> } catch(e) {
>> final def RECIPIENTS = emailextrecipients([
>> [$class: 'DevelopersRecipientProvider'],
>> [$class: 'CulpritsRecipientProvider']
>> ])
>> final def SUBJECT = "${env.JOB_NAME} ${env.BRANCH_NAME} - Build 
>> #${env.BUILD_NUMBER} - FAILED!"
>> final def CONTENT = "Check console output at ${env.BUILD_URL} to 
>> view the results."
>> if (RECIPIENTS != null && !RECIPIENTS.isEmpty()) {
>> mail to: RECIPIENTS, replyTo: "donot...@company.com 
>> ", subject: SUBJECT, body: CONTENT
>> } else {
>> mail to: "jenkins-admins", replyTo: "donot...@company.com 
>> ", subject: SUBJECT, body: CONTENT
>> }
>>
>>
>> /* Must re-throw exception to propagate error */
>> throw e
>> }
>>
>>
>>
>> torsdag 23. juni 2016 10.07.31 UTC+2 skrev Craig Rodrigues følgende:
>>>
>>> Yes, step mailer sends mail on fixed builds, but currentBuild.result is 
>>> null unless you
>>> set it.  The step mailer depends on currentBuild.result.
>>>
>>> --
>>> Craig
>>>
>>> On Thu, Jun 23, 2016 at 12:53 AM, Sverre Moe  wrote:
>>>
 Same solutions I thought about, to put a try-catch surrounding all the 
 stages in the build.
 However I could not find anything in those examples how to send email 
 on fixed builds. Unless step Mailer does that for you. I use Email-ext 
 because I want to a minimalist email content.

 It should only send out email on FAILED and SUCCESS(if previously 
 FAILED). I could do something like this if I had access to 
 previousBuild.result

 It seems the pipeline sets the currentBuild.result to SUCCESS or FAILED 
 at the end. Unless setting the result in the script the value is always 
 null.


 torsdag 23. juni 2016 09.31.20 UTC+2 skrev Craig Rodrigues følgende:
>
> Mike Caspar added email notification to this example:
>
>
> https://github.com/jenkinsci/pipeline-examples/blob/master/jenkinsfile-examples/nodejs-build-test-deploy-docker-notify/Jenkinsfile
>
> and my script does email notification similar to what you need
>
>
> https://github.com/freebsd/freebsd-ci/blob/master/scripts/build/build-test.groovy#L233
>
> You need to set and check the currentBuild.result value, and do 
> different things based on that.
>
> --
> Craig
>
> On Thu, Jun 23, 2016 at 12:20 AM, Sverre Moe  
> wrote:
>
>> One benefit with sending email in pipeline script is better control 
>> of which error in the pipeline deserves sending email and to whom.
>>
>> By adding a try-catch surrounding the code compile I send out email 
>> when it fails. That case the developers get notified only for errors 
>> that 
>> concern them.
>> try {
>> preInstall()
>> compileAndBuild()
>> postInstall()
>> } catch(e) {
>> final def RECIPIENTS = emailextrecipients([
>> [$class: 'DevelopersRecipientProvider'],
>> [$class: 'CulpritsRecipientProvider']
>> ])
>> final def SUBJECT = "${env.JOB_NAME} ${env.BRANCH_NAME} - Build 
>> #${env.BUILD_NUMBER} - FAILED!"
>> final def CONTENT = "Check console output at ${env.BUILD_URL} to 
>> view the results."
>> if (RECIPIENTS != null && !RECIPIENTS.isEmpty()) {
>> mail to: RECIPIENTS, replyTo: "donot...@company.com", subject
>> : SUBJECT, body: CONTENT
>

Re: Pipeline: Sending email on failed and fixed builds

2016-06-23 Thread Sverre Moe
I got Mailer to send success after failed.
I wish "mail" or "emailext" could support this as those allow to define the 
subject and body.

torsdag 23. juni 2016 10.58.51 UTC+2 skrev Sverre Moe følgende:
>
> Ok
> We went away from the Mailer because we wanted to minimize the content in 
> body.
>
> I tried with your example, but it did not send out email on success after 
> failed.
> } catch (caughtError) {
> currentBuild.result = "FAILURE"
> } finally {
>if (currentBuild.result != "ABORTED") {
>final def RECIPIENTS = emailextrecipients([
>[$class: 'DevelopersRecipientProvider'],
>[$class: 'CulpritsRecipientProvider']
>])
>
>step([$class: 'Mailer', notifyEveryUnstableBuild: true, 
> sendToIndividuals: true, recipients: RECIPIENTS])
> }
>
> /* Must re-throw exception to propagate error */
> if (err) {
> throw err
> }
> }
>
>
> Using the following will send out emails on every SUCCESS, regardless of 
> previous build result.
> emailext body: CONTENT, subject: SUBJECT, replyTo: 'donotre...@company.com', 
> recipientProviders: [[$class: 'CulpritsRecipientProvider'], [$class: 
> 'DevelopersRecipientProvider']]
>
> I could use the following to send out email on every failed build, but 
> will not get sent when build is fixed.
> } catch(e) {
> final def RECIPIENTS = emailextrecipients([
> [$class: 'DevelopersRecipientProvider'],
> [$class: 'CulpritsRecipientProvider']
> ])
> final def SUBJECT = "${env.JOB_NAME} ${env.BRANCH_NAME} - Build 
> #${env.BUILD_NUMBER} - FAILED!"
> final def CONTENT = "Check console output at ${env.BUILD_URL} to view 
> the results."
> if (RECIPIENTS != null && !RECIPIENTS.isEmpty()) {
> mail to: RECIPIENTS, replyTo: "donotre...@company.com", subject: 
> SUBJECT, body: CONTENT
> } else {
> mail to: "jenkins-admins", replyTo: "donotre...@company.com", 
> subject: SUBJECT, body: CONTENT
> }
>
>
> /* Must re-throw exception to propagate error */
> throw e
> }
>
>
>
> torsdag 23. juni 2016 10.07.31 UTC+2 skrev Craig Rodrigues følgende:
>>
>> Yes, step mailer sends mail on fixed builds, but currentBuild.result is 
>> null unless you
>> set it.  The step mailer depends on currentBuild.result.
>>
>> --
>> Craig
>>
>> On Thu, Jun 23, 2016 at 12:53 AM, Sverre Moe  wrote:
>>
>>> Same solutions I thought about, to put a try-catch surrounding all the 
>>> stages in the build.
>>> However I could not find anything in those examples how to send email on 
>>> fixed builds. Unless step Mailer does that for you. I use Email-ext because 
>>> I want to a minimalist email content.
>>>
>>> It should only send out email on FAILED and SUCCESS(if previously 
>>> FAILED). I could do something like this if I had access to 
>>> previousBuild.result
>>>
>>> It seems the pipeline sets the currentBuild.result to SUCCESS or FAILED 
>>> at the end. Unless setting the result in the script the value is always 
>>> null.
>>>
>>>
>>> torsdag 23. juni 2016 09.31.20 UTC+2 skrev Craig Rodrigues følgende:

 Mike Caspar added email notification to this example:


 https://github.com/jenkinsci/pipeline-examples/blob/master/jenkinsfile-examples/nodejs-build-test-deploy-docker-notify/Jenkinsfile

 and my script does email notification similar to what you need


 https://github.com/freebsd/freebsd-ci/blob/master/scripts/build/build-test.groovy#L233

 You need to set and check the currentBuild.result value, and do 
 different things based on that.

 --
 Craig

 On Thu, Jun 23, 2016 at 12:20 AM, Sverre Moe  
 wrote:

> One benefit with sending email in pipeline script is better control of 
> which error in the pipeline deserves sending email and to whom.
>
> By adding a try-catch surrounding the code compile I send out email 
> when it fails. That case the developers get notified only for errors that 
> concern them.
> try {
> preInstall()
> compileAndBuild()
> postInstall()
> } catch(e) {
> final def RECIPIENTS = emailextrecipients([
> [$class: 'DevelopersRecipientProvider'],
> [$class: 'CulpritsRecipientProvider']
> ])
> final def SUBJECT = "${env.JOB_NAME} ${env.BRANCH_NAME} - Build 
> #${env.BUILD_NUMBER} - FAILED!"
> final def CONTENT = "Check console output at ${env.BUILD_URL} to 
> view the results."
> if (RECIPIENTS != null && !RECIPIENTS.isEmpty()) {
> mail to: RECIPIENTS, replyTo: "donot...@company.com", subject: 
> SUBJECT, body: CONTENT
> } else {
> mail to: "jenkins-admin", replyTo: "donot...@company.com", 
> subject: SUBJECT, body: CONTENT
> }
> throw e
> }
> I need to re-throw the exception otherwise the pipeline continues.
>
> However I still want email to be sent out if there is an error 
> any

Re: Pipeline: Sending email on failed and fixed builds

2016-06-23 Thread Sverre Moe
Ok
We went away from the Mailer because we wanted to minimize the content in 
body.

I tried with your example, but it did not send out email on success after 
failed.
} catch (caughtError) {
currentBuild.result = "FAILURE"
} finally {
   if (currentBuild.result != "ABORTED") {
   final def RECIPIENTS = emailextrecipients([
   [$class: 'DevelopersRecipientProvider'],
   [$class: 'CulpritsRecipientProvider']
   ])

   step([$class: 'Mailer', notifyEveryUnstableBuild: true, 
sendToIndividuals: true, recipients: RECIPIENTS])
}

/* Must re-throw exception to propagate error */
if (err) {
throw err
}
}


Using the following will send out emails on every SUCCESS, regardless of 
previous build result.
emailext body: CONTENT, subject: SUBJECT, replyTo: 
'donotre...@company.com', recipientProviders: [[$class: 
'CulpritsRecipientProvider'], [$class: 'DevelopersRecipientProvider']]

I could use the following to send out email on every failed build, but will 
not get sent when build is fixed.
} catch(e) {
final def RECIPIENTS = emailextrecipients([
[$class: 'DevelopersRecipientProvider'],
[$class: 'CulpritsRecipientProvider']
])
final def SUBJECT = "${env.JOB_NAME} ${env.BRANCH_NAME} - Build 
#${env.BUILD_NUMBER} - FAILED!"
final def CONTENT = "Check console output at ${env.BUILD_URL} to view 
the results."
if (RECIPIENTS != null && !RECIPIENTS.isEmpty()) {
mail to: RECIPIENTS, replyTo: "donotre...@company.com", subject: 
SUBJECT, body: CONTENT
} else {
mail to: "jenkins-admins", replyTo: "donotre...@company.com", 
subject: SUBJECT, body: CONTENT
}


/* Must re-throw exception to propagate error */
throw e
}



torsdag 23. juni 2016 10.07.31 UTC+2 skrev Craig Rodrigues følgende:
>
> Yes, step mailer sends mail on fixed builds, but currentBuild.result is 
> null unless you
> set it.  The step mailer depends on currentBuild.result.
>
> --
> Craig
>
> On Thu, Jun 23, 2016 at 12:53 AM, Sverre Moe  > wrote:
>
>> Same solutions I thought about, to put a try-catch surrounding all the 
>> stages in the build.
>> However I could not find anything in those examples how to send email on 
>> fixed builds. Unless step Mailer does that for you. I use Email-ext because 
>> I want to a minimalist email content.
>>
>> It should only send out email on FAILED and SUCCESS(if previously 
>> FAILED). I could do something like this if I had access to 
>> previousBuild.result
>>
>> It seems the pipeline sets the currentBuild.result to SUCCESS or FAILED 
>> at the end. Unless setting the result in the script the value is always 
>> null.
>>
>>
>> torsdag 23. juni 2016 09.31.20 UTC+2 skrev Craig Rodrigues følgende:
>>>
>>> Mike Caspar added email notification to this example:
>>>
>>>
>>> https://github.com/jenkinsci/pipeline-examples/blob/master/jenkinsfile-examples/nodejs-build-test-deploy-docker-notify/Jenkinsfile
>>>
>>> and my script does email notification similar to what you need
>>>
>>>
>>> https://github.com/freebsd/freebsd-ci/blob/master/scripts/build/build-test.groovy#L233
>>>
>>> You need to set and check the currentBuild.result value, and do 
>>> different things based on that.
>>>
>>> --
>>> Craig
>>>
>>> On Thu, Jun 23, 2016 at 12:20 AM, Sverre Moe  wrote:
>>>
 One benefit with sending email in pipeline script is better control of 
 which error in the pipeline deserves sending email and to whom.

 By adding a try-catch surrounding the code compile I send out email 
 when it fails. That case the developers get notified only for errors that 
 concern them.
 try {
 preInstall()
 compileAndBuild()
 postInstall()
 } catch(e) {
 final def RECIPIENTS = emailextrecipients([
 [$class: 'DevelopersRecipientProvider'],
 [$class: 'CulpritsRecipientProvider']
 ])
 final def SUBJECT = "${env.JOB_NAME} ${env.BRANCH_NAME} - Build 
 #${env.BUILD_NUMBER} - FAILED!"
 final def CONTENT = "Check console output at ${env.BUILD_URL} to 
 view the results."
 if (RECIPIENTS != null && !RECIPIENTS.isEmpty()) {
 mail to: RECIPIENTS, replyTo: "donot...@company.com", subject: 
 SUBJECT, body: CONTENT
 } else {
 mail to: "jenkins-admin", replyTo: "donot...@company.com", 
 subject: SUBJECT, body: CONTENT
 }
 throw e
 }
 I need to re-throw the exception otherwise the pipeline continues.

 However I still want email to be sent out if there is an error anywhere 
 in the code. The Jenkins administrators should get an email if the build 
 scripts fails and has nothing to do with the code. I cannot put a 
 try-catch 
 everywhere in the code.

 Also how do I send out email on fixed builds? Do I have to do it 
 manually. Check the previous build, get the recipient list (culprits, 
 developers) from that build and send a 

Re: Pipeline: Sending email on failed and fixed builds

2016-06-23 Thread Craig Rodrigues
Yes, step mailer sends mail on fixed builds, but currentBuild.result is
null unless you
set it.  The step mailer depends on currentBuild.result.

--
Craig

On Thu, Jun 23, 2016 at 12:53 AM, Sverre Moe  wrote:

> Same solutions I thought about, to put a try-catch surrounding all the
> stages in the build.
> However I could not find anything in those examples how to send email on
> fixed builds. Unless step Mailer does that for you. I use Email-ext because
> I want to a minimalist email content.
>
> It should only send out email on FAILED and SUCCESS(if previously FAILED).
> I could do something like this if I had access to previousBuild.result
>
> It seems the pipeline sets the currentBuild.result to SUCCESS or FAILED at
> the end. Unless setting the result in the script the value is always null.
>
>
> torsdag 23. juni 2016 09.31.20 UTC+2 skrev Craig Rodrigues følgende:
>>
>> Mike Caspar added email notification to this example:
>>
>>
>> https://github.com/jenkinsci/pipeline-examples/blob/master/jenkinsfile-examples/nodejs-build-test-deploy-docker-notify/Jenkinsfile
>>
>> and my script does email notification similar to what you need
>>
>>
>> https://github.com/freebsd/freebsd-ci/blob/master/scripts/build/build-test.groovy#L233
>>
>> You need to set and check the currentBuild.result value, and do different
>> things based on that.
>>
>> --
>> Craig
>>
>> On Thu, Jun 23, 2016 at 12:20 AM, Sverre Moe  wrote:
>>
>>> One benefit with sending email in pipeline script is better control of
>>> which error in the pipeline deserves sending email and to whom.
>>>
>>> By adding a try-catch surrounding the code compile I send out email when
>>> it fails. That case the developers get notified only for errors that
>>> concern them.
>>> try {
>>> preInstall()
>>> compileAndBuild()
>>> postInstall()
>>> } catch(e) {
>>> final def RECIPIENTS = emailextrecipients([
>>> [$class: 'DevelopersRecipientProvider'],
>>> [$class: 'CulpritsRecipientProvider']
>>> ])
>>> final def SUBJECT = "${env.JOB_NAME} ${env.BRANCH_NAME} - Build
>>> #${env.BUILD_NUMBER} - FAILED!"
>>> final def CONTENT = "Check console output at ${env.BUILD_URL} to
>>> view the results."
>>> if (RECIPIENTS != null && !RECIPIENTS.isEmpty()) {
>>> mail to: RECIPIENTS, replyTo: "donot...@company.com", subject:
>>> SUBJECT, body: CONTENT
>>> } else {
>>> mail to: "jenkins-admin", replyTo: "donot...@company.com",
>>> subject: SUBJECT, body: CONTENT
>>> }
>>> throw e
>>> }
>>> I need to re-throw the exception otherwise the pipeline continues.
>>>
>>> However I still want email to be sent out if there is an error anywhere
>>> in the code. The Jenkins administrators should get an email if the build
>>> scripts fails and has nothing to do with the code. I cannot put a try-catch
>>> everywhere in the code.
>>>
>>> Also how do I send out email on fixed builds? Do I have to do it
>>> manually. Check the previous build, get the recipient list (culprits,
>>> developers) from that build and send a fixed build email message.
>>>
>>> --
>>> You received this message because you are subscribed to the Google
>>> Groups "Jenkins Users" group.
>>> To unsubscribe from this group and stop receiving emails from it, send
>>> an email to jenkinsci-use...@googlegroups.com.
>>> To view this discussion on the web visit
>>> https://groups.google.com/d/msgid/jenkinsci-users/dbb8fc19-458f-4114-937c-b5136b792562%40googlegroups.com
>>> 
>>> .
>>> For more options, visit https://groups.google.com/d/optout.
>>>
>>
>>

-- 
You received this message because you are subscribed to the Google Groups 
"Jenkins Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to jenkinsci-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/jenkinsci-users/CAG%3DrPVf-dvCr6oTt-UrxCnM4m63k939ALO%2Bm_78et3kr69htkQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Pipeline: Sending email on failed and fixed builds

2016-06-23 Thread Sverre Moe
Same solutions I thought about, to put a try-catch surrounding all the 
stages in the build.
However I could not find anything in those examples how to send email on 
fixed builds. Unless step Mailer does that for you. I use Email-ext because 
I want to a minimalist email content.

It should only send out email on FAILED and SUCCESS(if previously FAILED). 
I could do something like this if I had access to previousBuild.result

It seems the pipeline sets the currentBuild.result to SUCCESS or FAILED at 
the end. Unless setting the result in the script the value is always null.


torsdag 23. juni 2016 09.31.20 UTC+2 skrev Craig Rodrigues følgende:
>
> Mike Caspar added email notification to this example:
>
>
> https://github.com/jenkinsci/pipeline-examples/blob/master/jenkinsfile-examples/nodejs-build-test-deploy-docker-notify/Jenkinsfile
>
> and my script does email notification similar to what you need
>
>
> https://github.com/freebsd/freebsd-ci/blob/master/scripts/build/build-test.groovy#L233
>
> You need to set and check the currentBuild.result value, and do different 
> things based on that.
>
> --
> Craig
>
> On Thu, Jun 23, 2016 at 12:20 AM, Sverre Moe  > wrote:
>
>> One benefit with sending email in pipeline script is better control of 
>> which error in the pipeline deserves sending email and to whom.
>>
>> By adding a try-catch surrounding the code compile I send out email when 
>> it fails. That case the developers get notified only for errors that 
>> concern them.
>> try {
>> preInstall()
>> compileAndBuild()
>> postInstall()
>> } catch(e) {
>> final def RECIPIENTS = emailextrecipients([
>> [$class: 'DevelopersRecipientProvider'],
>> [$class: 'CulpritsRecipientProvider']
>> ])
>> final def SUBJECT = "${env.JOB_NAME} ${env.BRANCH_NAME} - Build 
>> #${env.BUILD_NUMBER} - FAILED!"
>> final def CONTENT = "Check console output at ${env.BUILD_URL} to 
>> view the results."
>> if (RECIPIENTS != null && !RECIPIENTS.isEmpty()) {
>> mail to: RECIPIENTS, replyTo: "donot...@company.com 
>> ", subject: SUBJECT, body: CONTENT
>> } else {
>> mail to: "jenkins-admin", replyTo: "donot...@company.com 
>> ", subject: SUBJECT, body: CONTENT
>> }
>> throw e
>> }
>> I need to re-throw the exception otherwise the pipeline continues.
>>
>> However I still want email to be sent out if there is an error anywhere 
>> in the code. The Jenkins administrators should get an email if the build 
>> scripts fails and has nothing to do with the code. I cannot put a try-catch 
>> everywhere in the code.
>>
>> Also how do I send out email on fixed builds? Do I have to do it 
>> manually. Check the previous build, get the recipient list (culprits, 
>> developers) from that build and send a fixed build email message.
>>
>> -- 
>> You received this message because you are subscribed to the Google Groups 
>> "Jenkins Users" group.
>> To unsubscribe from this group and stop receiving emails from it, send an 
>> email to jenkinsci-use...@googlegroups.com .
>> To view this discussion on the web visit 
>> https://groups.google.com/d/msgid/jenkinsci-users/dbb8fc19-458f-4114-937c-b5136b792562%40googlegroups.com
>>  
>> 
>> .
>> For more options, visit https://groups.google.com/d/optout.
>>
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Jenkins Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to jenkinsci-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/jenkinsci-users/c266be37-a45d-4310-8855-6b0ae727c4ff%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Pipeline: Sending email on failed and fixed builds

2016-06-23 Thread Craig Rodrigues
Mike Caspar added email notification to this example:

https://github.com/jenkinsci/pipeline-examples/blob/master/jenkinsfile-examples/nodejs-build-test-deploy-docker-notify/Jenkinsfile

and my script does email notification similar to what you need

https://github.com/freebsd/freebsd-ci/blob/master/scripts/build/build-test.groovy#L233

You need to set and check the currentBuild.result value, and do different
things based on that.

--
Craig

On Thu, Jun 23, 2016 at 12:20 AM, Sverre Moe  wrote:

> One benefit with sending email in pipeline script is better control of
> which error in the pipeline deserves sending email and to whom.
>
> By adding a try-catch surrounding the code compile I send out email when
> it fails. That case the developers get notified only for errors that
> concern them.
> try {
> preInstall()
> compileAndBuild()
> postInstall()
> } catch(e) {
> final def RECIPIENTS = emailextrecipients([
> [$class: 'DevelopersRecipientProvider'],
> [$class: 'CulpritsRecipientProvider']
> ])
> final def SUBJECT = "${env.JOB_NAME} ${env.BRANCH_NAME} - Build
> #${env.BUILD_NUMBER} - FAILED!"
> final def CONTENT = "Check console output at ${env.BUILD_URL} to view
> the results."
> if (RECIPIENTS != null && !RECIPIENTS.isEmpty()) {
> mail to: RECIPIENTS, replyTo: "donotre...@company.com", subject:
> SUBJECT, body: CONTENT
> } else {
> mail to: "jenkins-admin", replyTo: "donotre...@company.com",
> subject: SUBJECT, body: CONTENT
> }
> throw e
> }
> I need to re-throw the exception otherwise the pipeline continues.
>
> However I still want email to be sent out if there is an error anywhere in
> the code. The Jenkins administrators should get an email if the build
> scripts fails and has nothing to do with the code. I cannot put a try-catch
> everywhere in the code.
>
> Also how do I send out email on fixed builds? Do I have to do it manually.
> Check the previous build, get the recipient list (culprits, developers)
> from that build and send a fixed build email message.
>
> --
> You received this message because you are subscribed to the Google Groups
> "Jenkins Users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to jenkinsci-users+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/jenkinsci-users/dbb8fc19-458f-4114-937c-b5136b792562%40googlegroups.com
> 
> .
> For more options, visit https://groups.google.com/d/optout.
>

-- 
You received this message because you are subscribed to the Google Groups 
"Jenkins Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to jenkinsci-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/jenkinsci-users/CAG%3DrPVfNi%2B2j_4KmjwB4i5qfCFOs3BguHq9AR%3DRGS%3D%2Bn5MyWRw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.