我有一个部分解决方案。看起来工作项不可用,但变更集是可用的,只是名称不同。
首先我打开%programfiles%\Microsoft Team Foundation Server 1X.0\Application Tier\TFSJobAgent\Transforms\1033\BuildCompletedEvent.xsl 并将其内容替换为仅转储源xml 的内容。保留此文件的旧内容,因为您稍后需要对其进行编辑。
<xsl:template match="/">
<xsl:copy-of select="."/>
</xsl:template>
签入一些代码并开始构建以获取它,然后查看构建通知电子邮件以查看提供该 XSL 模板的源 XML。您将看到 AssociatedChangeset 已成为 AssociatedCommit 以及其他一些小更改。我很惊讶微软会更改模型的架构并忽略读取该模型的模板。
替换BuildCompletedEvent.xsl中的所有原始内容,然后在tb:BuildCompletedEvent模板里面,找到这个:
<xsl:if test="count(tb:Build/tb:Information/tb:BuildInformationNode[@Type = 'AssociatedChangeset']) > 0">
<h2 style="font-size: 12pt; margin-bottom: 0em;">
<span _locID="AssociatedChangesets">Associated Changesets</span>
</h2>
<div style="margin-left:1em">
<table style="font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif; font-size: 10pt;">
<xsl:apply-templates select="tb:Build/tb:Information/tb:BuildInformationNode[@Type = 'AssociatedChangeset']">
<xsl:sort select="tb:Fields/tb:InformationField[@Name = 'ChangesetId']/@Value"/>
</xsl:apply-templates>
</table>
</div>
</xsl:if>
然后把它放在前面:
<xsl:if test="count(tb:Build/tb:Information/tb:BuildInformationNode[@Type = 'AssociatedCommit']) > 0">
<h2 style="font-size: 12pt; margin-bottom: 0em;">
<span _locID="AssociatedCommits">Associated Commits</span>
</h2>
<div style="margin-left:1em">
<table style="font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif; font-size: 10pt;">
<xsl:apply-templates select="tb:Build/tb:Information/tb:BuildInformationNode[@Type = 'AssociatedCommit']">
<xsl:sort select="tb:Fields/tb:InformationField[@Name = 'CommitId']/@Value"/>
</xsl:apply-templates>
</table>
</div>
</xsl:if>
以及实际的变更集模板,找到这个:
<xsl:template match="tb:BuildInformationNode[@Type = 'AssociatedChangeset']">
<tr>
<td style="padding-right:2em">
<strong>
<xsl:value-of select="tb:Fields/tb:InformationField[@Name = 'CheckedInBy']/@Value"/>.
</strong>
<xsl:call-template name="linefeed2br">
<xsl:with-param name="StringToTransform" select="tb:Fields/tb:InformationField[@Name = 'Comment']/@Value"/>
</xsl:call-template>
-
<a>
<xsl:attribute name="href">
<xsl:value-of select="tb:Fields/tb:InformationField[@Name = 'WebAccessUri']/@Value"/>
</xsl:attribute>
Changeset <xsl:value-of select="tb:Fields/tb:InformationField[@Name = 'ChangesetId']/@Value"/>
</a>
</td>
</tr>
</xsl:template>
然后把它放在前面:
<xsl:template match="tb:BuildInformationNode[@Type = 'AssociatedCommit']">
<tr>
<td style="padding-right:2em">
<strong>
<xsl:value-of select="tb:Fields/tb:InformationField[@Name = 'Author']/@Value"/>.
</strong>
<xsl:call-template name="linefeed2br">
<xsl:with-param name="StringToTransform" select="tb:Fields/tb:InformationField[@Name = 'Comment']/@Value"/>
</xsl:call-template>
-
<a>
<xsl:variable name="href" select="tb:Fields/tb:InformationField[@Name = 'Uri']/@Value"/>
<xsl:variable name="fragment" select="'/_apis/tfvc/changesets/'"/>
<xsl:attribute name="href">
<!--<xsl:value-of select="replace(tb:Fields/tb:InformationField[@Name = 'Uri']/@Value, '/_apis/tfvc/changesets/', '/_versionControl/changeset/')"/>-->
<xsl:value-of select="substring-before($href,$fragment)"/>
<xsl:value-of select="'/_versionControl/changeset/'"/>
<xsl:value-of select="substring-after($href,$fragment)"/>
</xsl:attribute>
Changeset <xsl:value-of select="tb:Fields/tb:InformationField[@Name = 'CommitId']/@Value"/>
</a>
</td>
</tr>
</xsl:template>
请注意,XML 中的 Uri 返回 JSON 以进行 API 集成,因此需要进行字符串替换以使其成为 Web UI 的链接。我在使replace() 函数正常工作时遇到问题,因此是子字符串。
http://tfs:8080/tfs/DefaultCollection/_apis/tfvc/changesets/10516
http://tfs:8080/tfs/DefaultCollection/_versionControl/changeset/10516
我添加到现有模板而不是更改损坏的引用。我抱有一些希望,也许如果 TFS 升级将模型名称改回旧名称,那么模板仍然会匹配它们并将它们拉出来,而无需我进行任何编辑。
还要注意,更改后,需要做一些事情才能让 TFS 看到新模板。执行此操作时,我正在重新启动 TFS 服务:
TFSServiceControl quiesce|unquiesce
我没有提取单元测试失败的源 XML,但如果其他人提取了源 XML,并且它显示了哪些测试失败的详细信息,请分享您更新的 XSL。