我想在构建后脚本中获取构建请求者的用户名和/或电子邮件地址。
- Sidenote:我想要请求者,以便我可以在email-ext插件的pre-send脚本中动态设置构建后电子邮件通知的电子邮件发件人。*
AbstractBuild
内置了对AbstractBuild.getCulprits()
和AbstractBuild.hasParticipant(User user)
的支持,但我找不到检索请求者的方法。在reference list中也找不到任何对User
类的有用引用。
我想在构建后脚本中获取构建请求者的用户名和/或电子邮件地址。
AbstractBuild
内置了对AbstractBuild.getCulprits()
和AbstractBuild.hasParticipant(User user)
的支持,但我找不到检索请求者的方法。在reference list中也找不到任何对User
类的有用引用。
2条答案
按热度按时间qcuzuvrc1#
我设法通过构建的
Cause
解决了这个问题,作为recommended in this answer。构建请求者可以在构建的原因中找到的原因是完全有意义的,当你考虑它时:并非每个构建都由用户直接触发。如果它是由用户触发的,则构建的原因列表包含一个
Cause.UserIdCause
,以及用户的ID和名称。这段代码对我很有用。它通过cause从构建中提取用户名,并设置From和ReplyTo标头。我在email-ext Jenkins插件的pre-send脚本中使用它。
7kjnsjlb2#
只需发送邮件给构建请求者(即你在你的侧边所陈述的是你实际的目标/问题),你可以在管道中使用
recipientProviders
中的requestor()
的emailext步骤。来自email-ext插件文档的示例:
(This在问题发布后添加了一个功能:更新日志)