Thursday, July 7, 2011

HowTo: Pass build property from TeamCity into Freemaker email notification template

There is no magic, once you know it. My use-case was to prefix build number with configurable text before sending an email. The text was represented as TeamCity property system.tc.branch.number in my case.

TeamCity email templates are implemented with Freemaker. The TeamCity exposes all build properties as hash table on SBuild.getBuildOwnParameters().

In the template the instance of SBuild is accessible under build variable. Freemaker allows calling bean properties, in our case it would be build.buildOwnParameters, map lookup thru square-bracket syntax [] and literals are enclosed in apostrophes.

#${build.buildOwnParameters['system.tc.branch.number']}.${build.buildNumber}

1 comment:

David Lee said...

Thanks for your post. I tried your code example, but am getting this:

#[TEAMCITY TEMPLATE ERROR].1.0.2.17

Do you know why that is? Many thanks!