1

我安装了SetEnv 插件,它可以很好地在任务期间获取变量。

不幸的是,当我尝试在生成的状态电子邮件中使用 env 变量时,我一点运气都没有。这应该工作吗?

我已经尝试过 $VARNAME 和 ${VARNAME} - 这两个都没有在电子邮件中正确替换。

4

3 回答 3

3

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:

  • ${ENV, var} - Displays an environment variable.
  • ${BUILD_LOG_REGEX, regex, linesBefore, linesAfter, maxMatches, showTruncatedLines} - Displays lines from the build log that match the regular expression.
  • ${CHANGES_SINCE_LAST_SUCCESS, reverse, format, showPaths, changesFormat, pathFormat} - Displays the changes since the last successful build.
  • ${FAILED_TESTS} - Displays failing unit test information, if any tests have failed.

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.

于 2010-12-21T18:36:48.233 回答
2

这已经是可能的了。看起来您使用了错误的语法。如前所述,email-ext 插件具有访问环境变量的特定方法。尝试将其放在电子邮件正文中:

${ENV, var=VARNAME}

另一种方法是使用 Hudson 的执行 shell 功能在构建期间回显环境变量,并使用 BUILD_LOG_REGEX 对其进行解析。

例如,您可以在 Execute Shell 部分中使用它:

echo "Output: ${VARNAME}"

并在电子邮件中使用

${BUILD_LOG_REGEX, regex="^Output:", showTruncatedLines=false, substText=""}
于 2010-12-22T05:08:34.350 回答
0

看来我将不得不等待:

http://wiki.hudson-ci.org/display/HUDSON/The+new+EMailer

于 2010-12-21T19:20:15.453 回答