在 Jenkins 中,如何仅当分支失败是主分支时才发送电子邮件?

In Jenkins, How do I send emails only when the branch failed is the master branch?

我想在预发送脚本(来自 Editable-Email Notification 插件)中编写一个脚本来发送电子邮件(将取消标志设置为 true)只有当分支失败时才是 master 分支(如有 master以分支机构的名义)。我该怎么做?

How to trigger an email based on a specific condition for a successful build in Jenkins

您的 git 插件包含一个环境变量,或者您可以使用分支名称创建一个环境变量。然后使用上面的解决方案来投递邮件。

GIT 插件为您提供环境变量

GIT_BRANCH - Name of the remote repository (defaults to origin), followed by name of the branch currently being used, e.g. "origin/master" or "origin/foo"