在 TeamCity 5.1 通知中显示文件更改 [英] Show Changes with Files in TeamCity 5.1 Notification

查看:56
本文介绍了在 TeamCity 5.1 通知中显示文件更改的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在 TeamCity 5.1 电子邮件通知中包含已更改文件的列表,该通知会在构建成功或失败后发送给我的团队.我已经查看了 在 TeamCity 5.1 中自定义通知 文档,我查看了 config\_notifications\email 文件夹中的 .ftl 模板文件,但我没有找到可用模板变量或备用模板示例的列表.我能够在 TeamCity 的先前版本中包含已更改文件的列表(我认为它被称为文件更改"),但我在 TeamCity 5.1 中没有这样做.有什么想法吗?

解决方案

我能够让它在 TeamCity 6 中工作,所以我不知道它是否适用于 5.1,但这是我根据阅读所做的帮助文档中的示例.

编辑了 common.ftl 以添加

<#macro build_changes_files bean><#-- @ftlvariable name="buildType" type="jetbrains.buildServer.serverSide.SBuildType" --><#-- @ftlvariable name="bean" type="jetbrains.buildServer.notification.impl.ChangesBean" --><#-- @ftlvariable name="webLinks" type="jetbrains.buildServer.serverSide.WebLinks" --><div><#assign modNum=bean.modificationsNumber/><#if (modNum > 0)><小时><div><#assign changesLink><a href='${webLinks.getViewChangesUrl(bean.build)}'>${modNum} 更改<@plural modNum/></a></#assign>包含的更改 (${changesLink})<#if bean.changesClipped>,仅显示 ${bean.modifications?size}</#if>.

<#list bean.modifications as mod><#assign pers><#if mod.personal>(个人构建)</#if></#assign><#assign description=mod.description/><#if description?length == 0><#assign description='<no comment&gt;'/></#if><div><#assign modLink><a href='${webLinks.getChangeFilesUrl(mod.id, mod.personal)}'>${mod.changes?size} 文件<@plural mod.changes?size/></a></#assign>将 ${mod.displayVersion} ${pers} 更改为 ${mod.userName} (${modLink}):<i>${description?trim}</i>.<br><br><b>文件:</b><br><ul><#list mod.getFilteredChanges(buildType) as change><li>${change.getRelativeFileName()} - ${change.getChangeTypeName()}</#list>

</#list></#if>

</#宏>

然后在 *build_started.ftl*(或任何适当的 FTL 文件)中,我想列出我放置的已更改文件:

<@common.build_changes_files var.changesBean/>

I would like to include a list of changed files in the TeamCity 5.1 email notification which is sent out to my team after a successful or failed build. I have reviewed the Customizing Notifications in TeamCity 5.1 documentation and I have looked at the .ftl template files found within the config\_notifications\email folder, but I haven't found a list of available template variables or alternate template samples. I was able to include a list of changed files in prior versions of TeamCity (I think it was referred to as "Changes with Files"), but I'm not having any luck in doing so with TeamCity 5.1. Any ideas?

解决方案

I was able to get this to work in TeamCity 6 so I don't know if it works for 5.1 or not, but here's what I did based on reading an example from the help docs.

Edited common.ftl to add

<#macro build_changes_files bean>
  <#-- @ftlvariable name="buildType" type="jetbrains.buildServer.serverSide.SBuildType" -->
  <#-- @ftlvariable name="bean" type="jetbrains.buildServer.notification.impl.ChangesBean" -->
  <#-- @ftlvariable name="webLinks" type="jetbrains.buildServer.serverSide.WebLinks" -->
  <div>
    <#assign modNum=bean.modificationsNumber/>
    <#if (modNum > 0)>
      <hr>
      <div>
        <#assign changesLink><a href='${webLinks.getViewChangesUrl(bean.build)}'>${modNum} change<@plural modNum/></a></#assign>
        Changes included (${changesLink})<#if bean.changesClipped>,
        only ${bean.modifications?size} are shown</#if>.
      </div>
      <#list bean.modifications as mod>
        <#assign pers><#if mod.personal>(personal build)</#if></#assign>
        <#assign description=mod.description/>
        <#if description?length == 0><#assign description='&lt;no comment&gt;'/></#if>
        <div>
          <#assign modLink><a href='${webLinks.getChangeFilesUrl(mod.id, mod.personal)}'>${mod.changes?size} file<@plural mod.changes?size/></a></#assign>
          Change ${mod.displayVersion} ${pers} by ${mod.userName} (${modLink}):
          <i>${description?trim}</i>.
          <br>
          <br>
          <b>Files:</b>
          <br>
          <ul>
          <#list mod.getFilteredChanges(buildType) as change>
            <li>${change.getRelativeFileName()} - ${change.getChangeTypeName()}
            </li>
          </#list>
          </ul>
        </div>
      </#list>
    </#if>
  </div>
</#macro>

Then in *build_started.ftl* (or whatever appropriate FTL file) where I wanted to list the changed files I put:

<@common.build_changes_files var.changesBean/>

这篇关于在 TeamCity 5.1 通知中显示文件更改的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
其他开发最新文章
热门教程
热门工具
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆