How to include and reference content of build artifact file in email notifications templates

Hi,

We're in the process of moving from QuickBuild to TeamCity. Our builds generate an html test summary file in the artifacts dir of a build that our devs want included in their email notifications, like they are with QuickBuild. The html file is also used as a custom tab on the server showing the test summary. Of course, failed builds don't always produce artifacts, so the file doesn't always exist.

I attempted to access the contents through the existing FreeMarker templates and serverside objects directly, but this doesn't appear possible, and I'm now attempting to write a plugin to expose the contents to the email notification templates.

I've used http://confluence.jetbrains.com/display/TCD8/Extending+Notification+Templates+Model as a starting point, but it appears I need a reference to the current SBuild object, and I can't find an obvious way to obtain it in the TemplateProcessor. Can anyone shed light on how to accomplish this? The indication seems to be that if I can add the contents to the map as a string like "testsummaryreport", that I'd be able to reference it from the email templates just like other supplied objects - 'build', 'project', 'buildType''var.buildChanges', etc.

Is all this in the right direction? I feel like I'm on the cusp here...

Thanks,
Mickey

1 comment
Comment actions Permalink

Hi Michael,

There is a similar discussion in this issue: http://youtrack.jetbrains.com/issue/TW-34589
As mentioned there, the easiest way to accomplish the task is to write a TeamCity plugin and provide additional data to the FreeMarker.
As a starting point, I would suggest you to take a look at the sample plugin: https://github.com/jonnyzzz/TeamCity.PluginTemplate/tree/serverOnly
There are instructions how to create and build a plugin, which may be the hardest task for a first-timer. When you're sure your plugin works with TeamCity, you should try playing around with the custom TemplateProcessor (your reference link is right).
The answer to your question: you can find all necessary objects from the NotificationContext. The model map can be different depending on the event, e.g. there may be or may not be a "build" present, depending on whether the event is build related.
So if there is no "build", you should just ignore this event.

Hope this helps.
This is seems to be a commonly asked question, would you mind sharing your code, so that other can benefit from it?
Thanks.

0

Please sign in to leave a comment.