Jenkins運行結果發送郵件失敗的各種坑……


已在 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

這個問題找到解決辦法:

Jenkins在執行JUnit報告時報錯Test reports were found but none of them are new. Did leafNodes run? 問題解決: https://blog.csdn.net/lhh08hasee/article/details/82588539
——提到說,如果測試運行和JUnit插件運行間隔超過3秒,則插件將忽略這些文件。
——解決辦法:更新這個文件的時間
 
3、同時需要確保已經配置了 "Extended E-mail Notification" 
—— inspired by 【 Jenkins Email sending fails
(在Jerkins-->Manage Jenkins -->Configure System -->"Extended E-mail Notification" 中進行配置 ) 
 
——Extended E-mail Notification Plugin 插件的詳細講解

設置了郵箱之后,又報這個錯:

 

+ 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、根據另一個接口自動化的Jenkins任務,參考其具體的配置,對此UI自動化工程進行配置,如下:
    在:Jenkins --系統管理 --配置系統。
 4.1)Jenkins Location 
     

 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

   

 

 ——然后測試郵件發送就可以了!!!

 

【Reference】
1、Jenkins在執行JUnit報告時報錯Test reports were found but none of them are new. Did leafNodes run? 問題解決: https://blog.csdn.net/lhh08hasee/article/details/82588539
—— 提示需要配置 "Extended E-mail Notification" 
——Extended E-mail Notification Plugin 插件的詳細講解
4、jenkins郵件持續集成之后,顯示發送成功,未收到郵件問題: https://blog.csdn.net/zhichuan0307/article/details/105930543
5、Jenkins構建Job,通過Extended E-mail Notification發送郵件時遇到的問題: https://blog.csdn.net/Eri_Feng/article/details/80410701

6、Jenkins - 郵件配置

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM