Click here to Skip to main content
15,887,027 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I am working on to send an email on build failure to the users who had committed the code in Jenkins. I am using pipeline script. But i am struck now as i am manually adding the username. How to automatically add recipient mail in Jenkins.

Here is the code i have written.

emailtext attachLog: true,body: '', compressLog: true, recipientProviders: [[$class: 'DevelopersRecipientProvider']], subject:'Test results' emailtext body : 'Commit failure', subject: 'Test-failure', to: 'abc@xyz.com'


What I have tried:

emailtext attachLog: true,body: '', compressLog: true, recipientProviders: [[$class: 'DevelopersRecipientProvider']], subject:'Test results' emailtext body : 'Commit failure', subject: 'Test-failure', to: 'abc@xyz.com'
Posted
Updated 18-Sep-17 21:43pm

I got it solved i just added the below code!!!

           script{ def recipients = emailextrecipients([ [$class: 'DevelopersRecipientProvider'],[$class: 'CulpritsRecipientProvider']])
             
             mail to: recipients, subject: "Failure", body: "failure"
}
 
Share this answer
 
v2
You might fine this solution is a good one:
https://stackoverflow.com/a/50269906/20297969[^]
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900