Show Changes with Files in TeamCity 5.1 Notification

故事扮演 提交于 2019-12-10 22:54:18

问题


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?


回答1:


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/>



回答2:


The help link you've mentioned references the variable var.buildChanges. I believe this is exactly what you're looking for.



来源:https://stackoverflow.com/questions/2678837/show-changes-with-files-in-teamcity-5-1-notification

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!