python - Buildbot 不发送电子邮件?

标签 python continuous-integration buildbot

我有一个为软件项目运行的 buildbot 安装程序,我正在尝试像这样设置电子邮件通知:

from buildbot.status import mail
c['status'].append(mail.MailNotifier(fromaddr=BUILDBOT_EMAIL,
                                     mode=('failing'),
                                     extraRecipients=[NOTIFICATION_EMAIL],
                                     sendToInterestedUsers=False))

BUILDBOT_EMAIL 是一个字符串“buildbot@name-of-our-project.org”,NOTIFICATION_EMAIL 是一个包含我想要获取的电子邮件的字符串通知。

根据 documentation ,一切似乎都很好;我不会向感兴趣的用户发送邮件,因此不需要 lookup 参数。我只是试图将邮件发送到明确指定的地址,以防任何构建失败。我基本上是这样做的:

To get a simple one-message-per-build (say, for a mailing list), use the following form instead. This form does not send mail to individual developers (and thus does not need the lookup= argument, explained below), instead it only ever sends mail to the extra recipients named in the arguments:

mn = MailNotifier(fromaddr="buildbot@example.org",
                  sendToInterestedUsers=False,
                  extraRecipients=['listaddr@example.org'])

但是,即使我确实有失败的构建,也没有电子邮件到达。可能是什么原因?

根据示例,我使用 fromaddr 和简单地使用 buildbot@domain-name.org 地址的方式是否有问题?这个地址应该以某种方式在我们的域中注册吗?如果我改用 buildbot@localhost 会有什么不同吗?

问题会不会是我没有使用relayhost引起的?从文档中的示例来看,这似乎只需要设置为使用出站地址进行身份验证,而不是入站地址。

任何帮助将不胜感激。

最佳答案

与 kfunk 的建议类似,我从查看 twistd.log 开始。它包含以下内容:

2013-02-09 04:26:18+0000 [-] sending mail (868 bytes) to ['addr@example.com']
2013-02-09 04:26:18+0000 [-] Starting factory <twisted.mail.smtp.ESMTPSenderFactory instance at 0x31dc488>
2013-02-09 04:26:18+0000 [Uninitialized] SMTP Client retrying server. Retry: 5
2013-02-09 04:26:18+0000 [Uninitialized] SMTP Client retrying server. Retry: 4
2013-02-09 04:26:18+0000 [Uninitialized] SMTP Client retrying server. Retry: 3
2013-02-09 04:26:18+0000 [Uninitialized] SMTP Client retrying server. Retry: 2
2013-02-09 04:26:18+0000 [Uninitialized] SMTP Client retrying server. Retry: 1
2013-02-09 04:26:18+0000 [Uninitialized] Unhandled error in Deferred:
2013-02-09 04:26:18+0000 [Uninitialized] Unhandled Error
    Traceback (most recent call last):
    Failure: twisted.internet.error.ConnectionRefusedError: Connection was refused by other side: 111: Connection refused.

我尝试从机器的命令行手动发送电子邮件(使用sendmail),但失败了;结果发现没有 SMTP 服务器启动。解决方案是安装和配置邮件传输代理(对于 Ubuntu,最常见的似乎是 Postfix,所以我安装了它)。有很多关于如何安装和配置 Postfix 的教程和手册,所以一旦我找到线索,就很容易继续下去。

拥有自己的 SMTP 服务器需要考虑很多因素;例如找到一种方法来保护它免受未经授权的访问,否则它可能被例如使用。垃圾邮件发送者。但是,如果你想从 buildbot 获取电子邮件,你必须有一个 SMTP 服务器,所以值得努力学习和正确配置它。

关于python - Buildbot 不发送电子邮件?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14787336/

相关文章:

.net-core - CentOS 上 Bamboo 中的 .Net Core SFTP 集成测试

jenkins - 让 Jenkins CI 控制 SupervisorD

dependencies - 为具有钻石依赖项的构建器配置 buildbot

buildbot - 在 buildbot 中显示测试计数

python - Kivy 标签仅显示文本循环的最后一个元素

python - 了解并发进程

linux - 通过持续交付使用 GitLab CI 部署 Laravel 应用程序时是否需要 Laravel Envoy?

python - 已通过 Selenium 使用 GeckoDriver Firefox 丢弃浏览上下文

python - 从 Treeview 中选择自动将字符串数字转换为整数

python - 如何修复 Twisted python 与另一端的连接以不干净的方式丢失?