Jenkins - 发送邮件:ERROR: Could not send email as a part of the post-build publishers.

在Jenkins持续集成过程中遇到邮件发送失败的问题,错误信息显示连接SMTP主机时发生SocketException。问题根源在于邮件配置不正确,解决方案是创建一个包含邮箱账户和授权码的凭证,并在Extended E-mail Notification中进行配置,确保使用正确的SMTP设置。
摘要由CSDN通过智能技术生成

1、报错

Sending email to: XXXXXXXXXX@qq.com
[DeployPublisher][INFO] Deploying /appdata/jenkins/workspace/web_demo/target/web_demo.war to container Tomcat 8.x Remote with context null
  [/appdata/jenkins/workspace/web_demo/target/web_demo.war] is not deployed. Doing a fresh deployment.
  Deploying [/appdata/jenkins/workspace/web_demo/target/web_demo.war]
Not sent to the following valid addresses: XXXXXX@qq.com
ERROR: Could not send email as a part of the post-build publishers.
java.net.SocketException: Connection or outbound has closed
	at java.base/sun.security.ssl.SSLSocketImpl$AppOutputStream.write(SSLSocketImpl.java:1190)
	at com.sun.mail.util.TraceOutputStream.write(TraceOutputStream.java:116)
	at java.base/java.io.BufferedOutputStream.flushBuffer(BufferedOutputStream.java:81)
	at java.base/java.io.BufferedOutputStream.flush(BufferedOutputStream.java:142)
	at com.sun.mail.smtp.SMTPTransport.sendCommand(SMTPTransport.java:2429)
Caused: jakarta.mail.MessagingException: Can't send command to SMTP host;
  nested exception is:
	java.net.SocketException: Connection or outbound has closed
	at com.sun.mail.smtp.SMTPTransport.sendCommand(SMTPTransport.java:2431)
	at com.sun.mail.smtp.SMTPTransport.sendCommand(SMTPTransport.java:2418)
	at com.sun.mail.smtp.SMTPTransport.close(SMTPTransport.java:1394)
	at hudson.plugins.emailext.ExtendedEmailPublisher.sendMail(ExtendedEmailPublisher.java:603)
	at hudson.plugins.emailext.EmailExtStep$EmailExtStepExecution.run(EmailExtStep.java:249)
	at hudson.plugins.emailext.EmailExtStep$EmailExtStepExecution.run(EmailExtStep.java:182)
	at org.jenkinsci.plugins.workflow.steps.SynchronousNonBlockingStepExecution.lambda$start$0(SynchronousNonBlockingStepExecution.java:47)
	at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:515)
	at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
	at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
	at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
	at java.base/java.lang.Thread.run(Thread.java:834)

2、解决:

配置一个凭证username and password 类型的凭证:
username: 发送邮件的邮箱账户
pwd: 该邮箱的授权码

在:Extended E-mail Notification 中添加
在这里插入图片描述

在这里插入图片描述

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值