Jenkins:在开始构建时发送电子邮件通知 [英] Jenkins : sending email notification when starting a build

查看:423
本文介绍了Jenkins:在开始构建时发送电子邮件通知的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在Jenkins中,是否有一种在开始构建时发送邮件的方法. 我知道有一个构建后的电子邮件通知,它会在构建成功或失败后将邮件发送给给定的收件人.同样,我期待类似构建前通知的内容.

In Jenkins, Is there a way to send a mail when starting a build. I know there is a post-build email notification which sends mail to the given recipients after a successful or failure build. Similarly i am expecting something like pre build notification.

还有条件电子邮件,例如如果username == null发送给xyz@domain.com,否则发送给请求者.

Also is there a conditional email like if username == null send to xyz@domain.com else send it to requestor.

尝试过:几个插件,但对构建后的插件没有太大帮助

Tried : couple of plugins but didn't help much as they were post-build plugins

推荐答案

  1. 安装Email-ext插件: https://wiki.jenkins-ci.org/display/JENKINS/Email-ext+plugin
  1. Install the Email-ext plugin: https://wiki.jenkins-ci.org/display/JENKINS/Email-ext+plugin

请注意,即使您打算在构建之前发送电子邮件,构建后的操作也可以解决您的问题.

Notice that a post build action will solve your problem even though what you intend is to send an e-mail before the build.

  1. 然后,转到作业配置,然后选择"添加发布构建操作">"可编辑的电子邮件通知"

高级设置:

现在,在触发器处,只需添加一个新触发器,然后选择"构建之前"即可

Now, at Triggers, just add a new trigger and choose "Before Build"

对于第二部分,解决方案是将收件人列表放入环境变量(例如,名为 EMAIL_RECIPIENT 的字符串参数),然后在可编辑的电子邮件通知收件人列表框中将其用作 $ {EMAIL_RECIPIENT} .

For the second part, the solution is to put the recipient list in an environment variable (for example, a string parameter called EMAIL_RECIPIENT) and then use that in the editable email notification recipients list box as ${EMAIL_RECIPIENT}.

这篇关于Jenkins:在开始构建时发送电子邮件通知的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆