首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >在使用MailNotifier时,如何在电子邮件主题中获取buildbot构建属性?

在使用MailNotifier时,如何在电子邮件主题中获取buildbot构建属性?
EN

Stack Overflow用户
提问于 2016-06-14 10:02:49
回答 1查看 245关注 0票数 0

我正在尝试在我们的buildbot系统上发送自定义电子邮件状态通知。在使用MailNotifier时,我找不到在电子邮件主题中获取构建属性的方法。

我在messageFormatter回调函数参数中找到了build对象。但它只能在主体中使用,而不能在主体中使用。

我还尝试通过从我的master.cfg本身调用Json API来使用它,但它不起作用,buildbot服务器进入了某种无限循环。如果单独调用Json api,则可以很好地查询特定于构建的数据。

我使用的是buildbot 0.8.12,并且我是这个框架的新手。谢谢你的帮助。

EN

回答 1

Stack Overflow用户

发布于 2016-06-29 11:30:11

根据MailNotifier的文档字符串:

代码语言:javascript
复制
@param messageFormatter: function taking (mode, name, build, result,
    master_status) and returning a dictionary
    containing two required keys "body" and "type",
    with a third optional key, "subject". The
    "body" key gives a string that contains the
    complete text of the message. The "type" key
    is the message type ('plain' or 'html'). The
    'html' type should be used when generating an
    HTML message.  The optional "subject" key
    gives the subject for the email.

因此,您只需在结果字典中再添加一个条目,就可以得到您想要的结果。例如。

代码语言:javascript
复制
...
return {..., 'subject': 'Abracadabra %s' % build.getProperty('my-favourite-build-property')}
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/37801842

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档