Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to reference the Default Recipients set in Jenkins UI

I'm using jenkins emailext plugin, in the Jenkins global configuration UI, under Extended E-mail Notification section, I can set Default Recipients to be a list of recipients.

My question is, inside my Jenkinsfile, when I use emailext() step, how can I reference Default Recipients set in the UI, because the to argument for the step only seems to take a String.

like image 944
zanyman Avatar asked Sep 20 '25 03:09

zanyman


1 Answers

In the help message for the 'Default Recepients' options of the 'Extended E-mail Notification' plugin found in the Jenkins global configuration, one can find the not so clear statement:

Customize the default recipient list of the email notifications. The plugin will use this list if none is overridden in the project configuration. You may use the $DEFAULT_RECIPIENTS token in projects to include this default list, as well as add new addresses at the project level. To CC or BCC someone instead of putting them in the To list, add cc: or bcc: before the email address (e.g., cc:[email protected], bcc:[email protected]).

Taking a best guess how this could work I gave the following a try - and it worked:

emailext body: '', to: '$DEFAULT_RECIPIENTS', subject: 'To default recepient list'

Be careful not to use double quotes for the to: argument as groovy would jump in and try to replace it with the value of a variable called DEFAULT_RECIPIENTS.

What apparently doesn't work is leaving out the to: arguments. It'll just say that the list of recipients is empty.

like image 123
Joerg S Avatar answered Sep 21 '25 21:09

Joerg S