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

Jenkins pipeline emailext emailextrecipients: Can I also add specific, individual email address?

在 Jenkins 管道中,我将 emailext 与 emailextrecipients 一起使用,如下所示:

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

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

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

我不知道我是怎么错过的,但答案在 email-ext 文档中。对其他电子邮件地址使用 to:,并使用 recipientProviders: 而不是 to: emailextrecipients。所以有人会:

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

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
    )