简体   繁体   English

如何将TFS构建变量传递给TFS电子邮件警报xsl文件

[英]How to pass TFS build variable to TFS email alert xsl file

I am trying to trigger customized email alerts after a build is complete. 构建完成后,我试图触发自定义的电子邮件警报。 I have a set of test results stored in the build agent (hosted using IIS). 我在构建代理(使用IIS托管)中存储了一组测试结果。 I use TFS variables to store the path of the log results: 我使用TFS变量来存储日志结果的路径:

$(LogsPublishDirectory)\AppName_$(Build.BuildNumber)

I need to include, in the email, the information to access these logs (as a link) such as : 我需要在电子邮件中包含访问这些日志(作为链接)的信息,例如:

http://123.456.789.00:5555/AppName_$(Build.BuildNumber)

From the MSDN link( https://msdn.microsoft.com/en-us/library/bb552337(v=vs.120).aspx ), I figured I need to modify the XSL file of the build job. 通过MSDN链接( https://msdn.microsoft.com/en-us/library/bb552337(v=vs.120).aspx ),我认为我需要修改构建作业的XSL文件。

My question is: 我的问题是:

  1. How do I pass the TFS variables into the XSL file so that the logs link is generated dynamically? 如何将TFS变量传递到XSL文件中,以便动态生成日志链接?
  2. Please give guidance on how to edit the XSL file as I have never done this before? 请提供有关如何编辑XSL文件的指南,因为我从未做过此事?

How to edit the xsl file? 如何编辑xsl文件?

First to perform these procedures, you must be a member of the Administrators security group on the Team Foundation application-tier server. 首先要执行这些过程,您必须是Team Foundation应用程序层服务器上Administrators安全组的成员。

  1. Navigate to the file location Drive:\\%programfiles%\\Microsoft Team Foundation Server 14.0\\Application Tier\\TFSJobAgent\\Transforms\\1033 导航到文件位置Drive:\\%programfiles%\\Microsoft Team Foundation Server 14.0\\Application Tier\\TFSJobAgent\\Transforms\\1033
  2. Find the related xsl file.You should make a backup copy of any files that you want to change, and then test your changes. 找到相关的xsl文件。您应该对要更改的所有文件进行备份,然后测试所做的更改。
  3. Open the .xsl file in a notepad or some other text editor. 在记事本或其他文本编辑器中打开.xsl文件。 I choose VS to open the file. 我选择VS打开文件。
  4. Edit and save the file to show the message that you want in the notification email. 编辑并保存文件,以在通知电子邮件中显示所需的消息。

Here is the snippet of code to add a hyperlink to Bing . 这是向Bing添加超链接的代码段。

  <xsl:call-template name="link">
    <xsl:with-param name="format" select="'html'"/>
    <xsl:with-param name="link" select="'http://www.bing.com'"/>
    <xsl:with-param name="displayText" select="'Bing'"/>
  </xsl:call-template>

在此处输入图片说明

The variable will not change to the correspond value in the XSL file and e-mail. 该变量将不会更改为XSL文件和电子邮件中的相应值。 A workaround could be subscribe to the Event Service via TFS API and create your own e-mails. 解决方法是通过TFS API订阅事件服务并创建您自己的电子邮件。 It's probably more work than you need to though. 不过,这可能比您需要的工作还要多。

Check this blog for further information: TFS 2012 API Create Alert Subscriptions . 请查看此博客以获取更多信息: TFS 2012 API创建警报订阅 It applies to TFS2015 as well. 它也适用于TFS2015。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM