jenkins不会向多个收件人发送电子邮件

use*_*245 10 jenkins

我使用Jenkins email-ext插件在构建开始时发送电子邮件.当我只指定一个这样的电子邮件收件人时,一切顺利 - 我收到了电子邮件.

但是,当我指定更多收件人时,Jenkins停止发送电子邮件,尽管在构建日志中我可以看到他们正在发送(我没有得到它们)

我在构建日志中看到以下消息:"发送电子邮件至:abc@abc.com def@abc.com".我没有看到任何错误.

Him*_*ant 9

对我有用的是在电子邮件地址之间添加逗号和空格,例如:

x1@jenkins.com, x2@jenkins.com, x3@jenkins.com
Run Code Online (Sandbox Code Playgroud)

Jenkins作业的XML表示形式如下:

<maven2-moduleset plugin="maven-plugin@2.6">
...
 <reporters>
  <hudson.maven.reporters.MavenMailer>
   <recipients>x1@jenkins.com, x2@jenkins.com, x3@jenkins.com</recipients>
   <dontNotifyEveryUnstableBuild>false</dontNotifyEveryUnstableBuild>
   <sendToIndividuals>true</sendToIndividuals>
   <perModuleEmail>true</perModuleEmail>
  </hudson.maven.reporters.MavenMailer>
 </reporters>
</maven2-moduleset>
Run Code Online (Sandbox Code Playgroud)

它一直在发送邮件都很好.


小智 5

我还想知道为什么当给出一封电子邮件时它起作用,而当给出用逗号“,”分隔的多个电子邮件地址时它不起作用。设法让它发挥作用。

这对我有用

pipeline {
        agent any

        environment {
            EMAIL_INFORM = 'abc@gmail.com;def@gmail.com'
        }


        stages {
        }

        post {

            success {  
                emailext body: 'Check console output at $BUILD_URL to view the results.', 
                        to: "${EMAIL_INFORM}", 
                        subject: 'Jenkins - Released $PROJECT_NAME - #$BUILD_NUMBER'
            }

        }
    }
Run Code Online (Sandbox Code Playgroud)

您应该使用分号 ';' 在管道中通过声明性语法调用“emailext”时,而不是逗号“,”。

希望它现在有效。