Jenkins管道emailext emailextrecipients:我还可以添加特定的个人电子邮件地址吗?

Gen*_*ugh 9 jenkins email-ext jenkins-pipeline

在Jenkins管道中,我使用的是emailext,emailextrecipients如下所示:

emailext (
    subject: email_subject, 
    mimetype: 'text/html', 
    to: emailextrecipients([[$class: 'CulpritsRecipientProvider'],[$class: 'RequesterRecipientProvider']]), 
    body: email_body
    )
Run Code Online (Sandbox Code Playgroud)

我想在使用的列表中添加一个特定的电子邮件地址(例如admin@myshop.com)emailextrecipients.我希望收件人(我或经理或管理员)始终收到电子邮件,但收件人可能是罪魁祸首或请求者,我不希望emailext向该收件人发送两封电子邮件.

有没有办法合并'admin@myshop.com' emailextrecipients

Gen*_*ugh 19

我不知道我是怎么错过这个,但答案是在email-ext doc中.使用'to:'作为其他电子邮件地址,并使用'recipientProviders:'而不是'to:emailextrecipients'.所以有人会:

emailext (
    subject: email_subject, 
    mimetype: 'text/html', 
    to: 'admin@myshop.com',
    recipientProviders: [[$class: 'CulpritsRecipientProvider'],[$class: 'RequesterRecipientProvider']], 
    body: email_body
    )
Run Code Online (Sandbox Code Playgroud)

  • 您能否添加包含此信息的 email-ext 文档的链接 (3认同)

小智 5

万一您需要对电子邮件目标使用条件逻辑,对Generic Ratzlaugh的回答略有不同。

def myProviders = [ [$class: 'CulpritsRecipientProvider'], [$class: 'DevelopersRecipientProvider'] ];

myProviders.add ( [$class: 'RequesterRecipientProvider'] );

emailext (
    subject: email_subject, 
    mimetype: 'text/html', 
    to: 'admin@myshop.com',
    recipientProviders: myProviders, 
    body: email_body
    )
Run Code Online (Sandbox Code Playgroud)