How to read the environment variables in groovy email template 邮件模板中读取系统环境变量
2017-07-03 12:24
1041 查看
down vote | If you are using the email-ext Jenkins plugin to send out emails, there is a "build" object that contains a lot of information about your Jenkins job. I would do the following: Print out the properties inside this object by adding the following code to your template: <% println build.properties.collect{it}.join('<br />') %> View the email template output. You can either use the Jenkins "Email Template Testing" feature or just run your job. You should see a whole bunch of "KEY=VALUE" print outs. Look for the environment variable you are interested in. If your environment variable is listed in environment={BUILD_NUMBER=45, BUILD_DISPLAY_NAME=#45...}, you can just call build.environment['BUILD_NUMBER']to get 45. If you want to inject custom environment variables I would suggest installing the Env Inject Plugin, defining your variables through that plugin and then looking for the variable in build.envVars 就是说 build这个对象有当前build的很多信息, 但是这个在email groovy template里面怎么引用系统的变量呢 方法一: <% println build.environment['BUILD_NUMBER'] %> 方法二: <%=build.environment['BUILD_NUMBER']%> 如: <td><span class="fail"><%=build.environment['BUILD_NUMBER']%></span></td> |
相关文章推荐
- How to delete all email in the mail server using telnet & WCScript - 如何用 Telnet 删除邮件服务器上的所有邮件
- ubunbtu add Environment variables to system(ubuntu添加环境变量到系统的三种方法)
- 如何Eclipse改变模板中${user}变量,How to change the variable ${user} used in the eclipse templates.
- How to separate the implementation and definition for template function in c++
- How to get a type in C++ when its template argument is the argument
- how to read directory name using std c in the linux
- How to organize the Template Files in C++
- How to set JAVA environment variables in Linux or CentOS
- How to read video frames in hadoop?如何在Hadoop中读取视频帧?
- R12: How to add Microsoft Excel as Type to the Create Template List of Values in BI Publisher (Doc ID 1343225.1)
- [eZ publish] how to test the variables that exist in the url
- How to Read and Analyze the Email Header Fields and Information about SPF, DKIM, SpamAssassin
- prjGetWriteINIFile - How to Read-Write INI file using VB & API - 读取/写入INI文件 - VB6 + API - SourceCode - HackerJLY
- How to find child controls that are located in the template of a parent control
- How to build the environment of MSYS in the windows?
- Tips: How to use system environment variables in VS 2008 Post-Build events?
- [eZ publish] When a ezxml embed an video, how to get the ezxml object in the video embed template?
- How to Set and Unset Local, User and System Wide Environment Variables in Linux
- 如何用th:attr标签在thymeleaf模板中设置属性-原标题:How To Set Attributes in Thymeleaf Template using th:attr?
- 环境变量(The Environment Variables)