如何触发基于特定条件的电子邮件,以便在Jenkins中成功构建 [英] How to trigger an email based on a specific condition for a successful build in Jenkins

查看:1017
本文介绍了如何触发基于特定条件的电子邮件,以便在Jenkins中成功构建的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

每当某个条件在成功构建的后构建步骤的执行shell中成立时,我想触发电子邮件发送。问题是,即使条件不成立,构建也被视为成功

Whenever a certain condition holds true in the Execute shell of a Post-build step for a successful build, I want to trigger an email send. The problem is that, even when the condition doesn't hold true, the build is considered a success.

我试图实现:

if [condition == true]; then
  <do some action1>
  exit 0; //This success code should trigger email
else
  <do different action2>
  exit 0; //This success code should not trigger email
fi

退出代码为0的上述操作都是有效的,并且是成功构建。如何根据Jenkins中的某些条件成功发送电子邮件?

The exit codes are 0 as both of the actions above are valid and it's a successful build. How do I send an email on success based on some criteria in Jenkins?

推荐答案

能够使用电子邮件插件插件构建此插件。

You should be able to build this using the Email-ext plugin. It will allow you to create custom triggers and specify the content of the email.

添加:使用来自检查环境的插件的脚本 - 建构后触发器变量,您在后构建脚本中设置以确定是否应发送邮件。如果在其他后构建脚本之前评估After Build触发器,那么您可能需要将您的后构建脚本移动到构建本身。

Addition: Use a 'Script - After Build' trigger from the plugin that checks on an environment variable that you set in your post build script to determine if the mail should be sent or not. Possibly you will need to move your post-build script to the build itself if the 'After Build' trigger is evaluated before other post-build scripts.

这篇关于如何触发基于特定条件的电子邮件,以便在Jenkins中成功构建的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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