Are setenv hudson plugin variables accessible in status email?

为君一笑 提交于 2019-12-09 14:12:40

问题


I installed the SetEnv plugin and it works fine for getting the variables during a task.

unfortunately when i try to use the env variable in the resulting status email I have no luck at all. Is this supposed to work?

I've tried both $VARNAME and ${VARNAME} - neither of which get replaced correctly in the email.


回答1:


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.




回答2:


This is possible already. It looks like you're using the wrong syntax. As mentioned previously, the email-ext plugin has a specific method for accessing environment variables. Try putting this in the email body instead:

${ENV, var=VARNAME}

An alternative method would be to use Hudson's execute shell feature to echo the environment variable during the build and parsing for it using BUILD_LOG_REGEX.

For example, you could have this in the Execute Shell part:

echo "Output: ${VARNAME}"

and parse it in the email using

${BUILD_LOG_REGEX, regex="^Output:", showTruncatedLines=false, substText=""}



回答3:


It looks like I will have to wait for this:

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



来源:https://stackoverflow.com/questions/4484058/are-setenv-hudson-plugin-variables-accessible-in-status-email

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!