如何调试Jenkin的`emailext`插件?

问题描述 投票:0回答:2

emailext
是迄今为止 Jenkins 和 Jenkinsfiles 最受欢迎的电子邮件插件。

如何调试?

无法发送预期的电子邮件,且没有错误消息。

emailext
的文档并未指示任何类型的返回值、回调或任何其他获取函数调用状态或结果的方式。

一般来说,有哪些方法(如果有)可以用于调试此类内容?

(如果您对我的具体用例感到好奇,我将嵌入我的代码)

emailext(
    to: "[REDACTED]@[REDACTED].com",
    replyTo: 'no-reply@[REDACTED].com',
    subject: '$DEFAULT_SUBJECT',
    body: getEmailBody()
)
jenkins jenkins-pipeline jenkins-plugins
2个回答
3
投票

您可以在

Manage Jenkins > Configure System > Extended E-mail Notification
下启用插件的调试模式,然后选中复选框,如下图所示:

在构建的控制台输出中,如果您调用

emailext 
,您应该会看到更多日志。


0
投票

emailext异常如何处理?或者它有返回值吗?

我的需求是基于以下例外情况,我想要执行一些操作。但异常没有被捕获。

try {
    emailext (
        subject: "${jobName} - Build #${buildNumber} - Pipeline Status",
        body: htmlContent,
        mimeType: 'text/html',
        attachmentsPattern: includeAttachment ? attachmentFilePath : null,
        to: '[email protected]'
    )
} catch (Exception e) {
    echo "XXX Failed to send email: ${e.message}"
}

控制台日志:

DEBUG: getProvider() returning jakarta.mail.Provider[TRANSPORT,smtp,org.eclipse.angus.mail.smtp.SMTPTransport,Oracle]
DEBUG SMTP: need username and password for authentication
DEBUG SMTP: protocolConnect returning false, host=smtp.office365.com, user=jenkins, password=<null>
DEBUG SMTP: useEhlo true, useAuth true
DEBUG SMTP: trying to connect to host "smtp.office365.com", port 587, isSSL false
MailConnectException message: Couldn't connect to host, port: smtp.office365.com, 587; timeout 60000
Next SocketTimeoutException message: Connect timed out
[Pipeline] }
[Pipeline] // node
[Pipeline] End of Pipeline
Finished: SUCCESS
© www.soinside.com 2019 - 2024. All rights reserved.