如何根据詹金斯中的通过/失败作业发送电子邮件内容

How to send email content based on pass / fail jobs in jenkins

我想知道我是否可以在 jenkins 中根据通过/失败条件更改电子邮件的上下文。

我正在使用可编辑的电子邮件通知插件,如果构建失败,我在其中看不到任何更改电子邮件上下文的选项。有可用的触发选项,但这是我们要根据工作条件通知给谁。

我想做的是如果构建通过我想发送 html link (这是我在默认内容选项中设置的)但我不想发送它失败,因为在失败场景中没有关于 link 的可用报告。所以在这种情况下,如果我可以发送控制台日志

,我可以不用发送 hyper link

您可以使用电子邮件扩展插件中的 DEFAULT_PRESEND_SCRIPT 取消电子邮件并修改电子邮件内容

我认为您错过了每个触发器的 advanced 按钮。

  • 失败

    Advanced Settings --> Add Trigger --> Failure Any --> Advanced ---> Content,
    and then put the Failure content here.

  • 成功

    Advanced Settings --> Add Trigger --> Success --> Advanced ---> Content,
    and then put the Success content here.