Include git branch name and latest commit SHA in TeamCity successfull email template

Original question was on SO.

I have to include branch name and latest git commit SHA in TeamCity successful email template.

I've added these lines to the standard build_successful.ftl email template file:

<#global body>


Commit: ${build.buildNumber}

Branch: ${build.branch.displayName}


but got this email:

Commit: 77
I've found that TC server side API model exposes these methods:

I've tried ${build.vcs.number} and got the same template error.
I can't figure out how to obtain required info and where in the source of git plugin to find classes that exposes current vcs info?

We are using:

  • TeamCity 8
  • git provider by JetBrains
  • windows host
1 comment
Comment actions Permalink

If you want to include information about build revisions in your notification you can try using something like this (see also SBuild.getRevisions method):

      <#list build.revisions as revision>
        Revision: ${revision.repositoryVersion.displayVersion}
        VCS branch:  ${revision.repositoryVersion.vcsBranch}

A couple of notes:
- there can be more than one VCS root in build, so number of revisions corresponds to number of VCS roots
- if changes are not yet collected for the build, or some error occurred while changes collecting, collection of revisions will be empty


Please sign in to leave a comment.