Include git branch name and latest commit SHA in TeamCity successfull email template
Hello,
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}
...
</#global>
but got this email:
Commit: 77
Branch: [TEAMCITY TEMPLATE ERROR]
I've found that TC server side API model exposes these methods: http://javadoc.jetbrains.net/teamcity/openapi/8.0/jetbrains/buildServer/Build.html#getBuildNumber() http://javadoc.jetbrains.net/teamcity/openapi/8.0/jetbrains/buildServer/serverSide/Branch.html#getDisplayName()
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
Please sign in to leave a comment.
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}
</#list>
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