我安装了SetEnv 插件,它可以很好地在任务期间获取变量。
不幸的是,当我尝试在生成的状态电子邮件中使用 env 变量时,我一点运气都没有。这应该工作吗?
我已经尝试过 $VARNAME 和 ${VARNAME} - 这两个都没有在电子邮件中正确替换。
我安装了SetEnv 插件,它可以很好地在任务期间获取变量。
不幸的是,当我尝试在生成的状态电子邮件中使用 env 变量时,我一点运气都没有。这应该工作吗?
我已经尝试过 $VARNAME 和 ${VARNAME} - 这两个都没有在电子邮件中正确替换。
The simplest way to use environment variables (or any variables) in your email notifications is by using the Email-ext plugin.
Check their "Content token reference" for specifics but in short you get much more sophisticated substitution. Heres a few I use regularly:
The plugin makes it easy to define a base "global" template in the Hudson configuration then sort of "extend" that template in your job configuration- adding additional detail. It also allows you to route notifications more granularly based on the build status/outcome.
这已经是可能的了。看起来您使用了错误的语法。如前所述,email-ext 插件具有访问环境变量的特定方法。尝试将其放在电子邮件正文中:
${ENV, var=VARNAME}
另一种方法是使用 Hudson 的执行 shell 功能在构建期间回显环境变量,并使用 BUILD_LOG_REGEX 对其进行解析。
例如,您可以在 Execute Shell 部分中使用它:
echo "Output: ${VARNAME}"
并在电子邮件中使用
${BUILD_LOG_REGEX, regex="^Output:", showTruncatedLines=false, substText=""}