简体   繁体   English

Jenkins email-ext 插件为特定的构建失败添加触发器

[英]Jenkins email-ext plugin add a trigger for a specific build failure

I have email-ext plugin configured on Jenkins.我在 Jenkins 上配置了 email-ext 插件。 Currently I'm sending mails using following triggers.目前我正在使用以下触发器发送邮件。

  • Failure-1st第一次失败
  • Failure-2nd失败-2nd
  • Failure-Still失败-静止
  • Success成功

What I need to know, is there a way to add a custom trigger to send mails on a specific build failure我需要知道的是,有没有办法添加自定义触发器以在特定构建失败时发送邮件

assume that I need to send a mail on build Failure-4th假设我需要在第 4 次构建失败时发送邮件

You can use Trigger Scripts in groovy to define before or after the build if the email must be send or not.您可以在 groovy 中使用 Trigger Scripts 来定义构建之前或之后是否必须发送电子邮件。 There are four objects added to the model for the script to use to interact with the build.有四个对象添加到模型中,供脚本用于与构建交互。

  • build: This is the current build, usually a child class of AbstractBuild build:这是当前构建,通常是AbstractBuild的子类
  • project: The project object that the current build was started from, usually a child class of AbstractProject project:当前构建开始的项目对象,通常是AbstractProject的子类
  • rooturl: The Jenkins instance root URL, useful for links. rooturl:Jenkins 实例根 URL,用于链接。
  • out: A PrintStream that can be used to log messages to the build log. out:可用于将消息记录到构建日志的PrintStream

The last line in the script should resolve to a boolean true or false .脚本中的最后一行应该解析为布尔值truefalse

So I guess you can do what you want if you use a Groovy Script.所以我想如果你使用 Groovy 脚本,你可以做你想做的。 For more info check: e-mail ext欲了解更多信息,请查看:电子邮件分机

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM