0

I want to send email to developers who commited something in the SVN repo in the Jenkins Pipeline.

I have a try and catch (similiar to this try-catch and this try-catch2):

catch(Exception e) {
    String error = "${e}"
    emailext body: '$DEFAULT_CONTENT', 
    subject: '$DEFAULT_SUBJECT', 
    to: 'cronaldo'
}

If anything goes wrong with the build it will send an email to cronaldo (for example; cristiano.ronaldo@hisdomain.com). But this is hardcoded into the catch. I want to have something like get_commiters_id (to: get_commiters_id) where it gets the id based on a change in the SVN repo by one or many users.

Is there a way to get the user_id from jenkins? I know that the email-ext plugin has a $default_recipients which sends an email to the user who started the build. The email should be sent when it triggers if something goes wrong.

I guess what I want is the Culprits.

Community
  • 1
  • 1
gants
  • 173
  • 1
  • 1
  • 13

2 Answers2

0

You can install the Email-extension plugin,

It has the ability to send Email to Culprits in his advanced options.

enter image description here

Shahar Hamuzim Rajuan
  • 5,610
  • 9
  • 53
  • 91
0

Answer: Set an Email-Ext trigger in your jenkins job with Culprits as Send To.

jenkins jobs - under Post-build Actions - in Editable Email Notification (Email-Ext section) - choose Advanced. Add or edit a trigger. (You can see trigger options and Send To options as in screen shot from answer by @Shachar Hamuzim Rajuan ) Choose Culprits as the Send To.

gaoithe
  • 4,218
  • 3
  • 30
  • 38