已在 Jenkins的 job-構建后操作設置了郵件發送通知:(但是發送不成功,且報錯)
1、跑完工程后,發送郵件觸發失敗 ?
Email was triggered for: Failure - Any Sending email for trigger: Failure - Any An attempt to send an e-mail to empty list of recipients, ignored. Finished: FAILURE
2、使用上一次跑的測試報告index.html(因為跑一份新的需要1個多小時,成本太大,),來打包發郵件,會報這個錯誤:
+ zip -r report.zip test-output/index.html
updating: test-output/index.html (deflated 96%)
Recording test results
ERROR: Step ‘Publish JUnit test result report’ failed: Test reports were found but none of them are new. Did leafNodes run?
For example, /Users/XXX/.jenkins/workspace/YYY-project/test-output/index.html is 23 分 old
Email was triggered for: Failure - Any
Sending email for trigger: Failure - Any
An attempt to send an e-mail to empty list of recipients, ignored.
Finished: FAILURE
這個問題找到解決辦法:
設置了郵箱之后,又報這個錯:
+ zip -r report.zip test-output/index.html
updating: test-output/index.html (deflated 96%)
Recording test results
ERROR: Step ‘Publish JUnit test result report’ failed: Test reports were found but none of them are new. Did leafNodes run?
For example, /Users/yyy/.jenkins/workspace/CXXX/test-output/index.html is 1 小時 39 分 old
Checking for post-build
Performing post-build step
Checking if email needs to be generated
Email was triggered for: Failure - Any
Sending email for trigger: Failure - Any
messageContentType = text/html; charset=UTF-8
Collecting change authors...
build: 47
Adding recipients from trigger recipient list
Successfully created MimeMessage
An attempt to send an e-mail to empty list of recipients, ignored.
Some error occurred trying to send the email...check the Jenkins log
Finished: FAILURE

4.2)Extended E-mail Notification

4.3)郵件通知

5、build #55 又發生下面這個錯: —— Publish Junit test result report的問題,換成 Publish HTML Report 就不會報此錯了。(詳見:Jenkins安裝 HTML Publisher plugin插件)
+ zip -r report.zip test-output/index.html
adding: test-output/index.html (deflated 94%)
Recording test results
ERROR: Step ‘Publish JUnit test result report’ aborted due to exception:
org.xml.sax.SAXParseException; lineNumber: 670; columnNumber: 36; 在實體引用中, 實體名稱必須緊跟在 '&' 后面。
at com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.createSAXParseException(ErrorHandlerWrapper.java:203)
at com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.fatalError(ErrorHandlerWrapper.java:177)
at com.sun.org.apache.xerces.internal.impl.XMLErrorReporter.reportError(XMLErrorReporter.java:400)
at com.sun.org.apache.xerces.internal.impl.XMLErrorReporter.reportError(XMLErrorReporter.java:327)
at com.sun.org.apache.xerces.internal.impl.XMLScanner.reportFatalError(XMLScanner.java:1472)
6、出現的終極大問題:
【SendFailedException message: 451 5.7.3 STARTTLS is required to send mail [SHAPR01CA039.CHNPR01.prod.partner.outlook.cn] 】
按照對應的內容配置好了,項目構建也成功了,發送報告郵件的時候,報錯。
百度了這個錯,並沒有找到,最后通過FQGoogle找到的一個回答是:
需要去修改Jenkins啟動命令文件,在該文件中加一句命令: -Dmail.smtp.starttls.enable=true
可是找到這個一個類似的文件:是jenkins_runner.sh,發現它里面已經有上述的那句命令了……(暈了)
所以,這個也解決不了……
7、問了下IT負責人,建議SMTP服務器和端口換一個試試,於是試了如下:
smtp服務器:XXX-com.mail.protection.partner.outlook.cn
端口 25
——然后測試郵件發送就可以了!!!