Are setenv hudson plugin variables accessible in s

2019-04-02 09:48发布

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.

3条回答
爱情/是我丢掉的垃圾
2楼-- · 2019-04-02 10:01

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.

查看更多
狗以群分
3楼-- · 2019-04-02 10:23

It looks like I will have to wait for this:

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

查看更多
欢心
4楼-- · 2019-04-02 10:24

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=""}
查看更多
登录 后发表回答