电子邮件分机和工作流/管道 - 一些令牌没有被扩展? [英] Email-ext and Workflow/Pipeline - some tokens not being expanded?

查看:11
本文介绍了电子邮件分机和工作流/管道 - 一些令牌没有被扩展?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试在 Jenkins 管道作业中使用 email-ext 插件,但是在自由式作业中使用 email-ext 时我认为理所当然的大多数令牌都没有被扩展?

I'm trying to use the email-ext plugin in a Jenkins pipeline job, but most of the tokens I take for granted when using email-ext in a freestyle job aren't being expanded?

例如

node {
    emailext body: '${DEFAULT_CONTENT}', mimeType: 'text/html', replyTo: '$DEFAULT_REPLYTO', subject: '${DEFAULT_SUBJECT}', to: '$DEFAULT_RECIPIENTS'
}

生成电子邮件:

主题:

$PROJECT_NAME - 版本号 $BUILD_NUMBER - $BUILD_STATUS!

$PROJECT_NAME - Build # $BUILD_NUMBER - $BUILD_STATUS!

主体:

$PROJECT_NAME - Build # $BUILD_NUMBER - $BUILD_STATUS:检查 $BUILD_URL 的控制台输出以查看结果.

$PROJECT_NAME - Build # $BUILD_NUMBER - $BUILD_STATUS: Check console output at $BUILD_URL to view the results.

公平地说,这是在一般配置中设置的内容.但是,这些令牌都没有扩展,如果我直接从工作流中使用它们,它们也不会扩展,例如

Which are, in fairness, what is set in the general configuration. However, none of those tokens are expanded, and if I use them directly from workflow, they're not expanded either, e.g.

emailext body: '$PROJECT_NAME', mimeType: 'text/html', replyTo: '$DEFAULT_REPLYTO', subject: '${DEFAULT_SUBJECT}', to: '$DEFAULT_RECIPIENTS'

如果我能够使用 $SCRIPT 引用我现有的基于 Groovy 的电子邮件模板,那就没问题了,但这些模板也没有扩展.

This would be 'okay' if I was able to reference my existing Groovy-based email templates using $SCRIPT, but those aren't expanded either.

如果我遗漏了一些非常明显的东西,我深表歉意 - 我对 Pipeline 还没有太多经验 - 到目前为止,缺乏电子邮件分机支持使我无法继续前进.

Apologies if I'm missing something incredibly obvious - I don't have much experience with Pipeline yet - the lack of email-ext support has stopped me from moving across thus far.

我今天通过全新安装 Jenkins 1.651、email-ext 2.41.3 和 Pipeline 1.14 进行了测试.

I tested today by clean installing Jenkins 1.651, email-ext 2.41.3 and Pipeline 1.14.

推荐答案

令牌与 AbstractBuild 高度相关,工作流不使用该令牌.因此,令牌现在不会被正确替换.我需要修改令牌宏插件(这是令牌扩展的基础),以便它可以与 Run 对象一起工作,而不仅仅是 AbstractBuild,但这是一项我还没有改变的大任务.您可以使用工作流 DSL 生成相同的内容.

The tokens are highly tied to AbstractBuild, which workflow doesn't use. So, the tokens won't be replaced correctly right now. I need to modify the token-macro plugin (which is the basis for the token expansion) so that it will work with a Run object instead of just AbstractBuild, but this is a large task that I haven't had the change to do yet. You could generate the same content using the workflow DSL.

这篇关于电子邮件分机和工作流/管道 - 一些令牌没有被扩展?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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