Wanting to customize build success email template...

Hello,
Looking for an example/tutorial on adding my own custom content to the body of the build_successful.ftl template.
Basically, I have a number of env.* paramerters that I set during the build run and upon a successful completion (currently) I cobble these up in a final (Powershell script) build task that rolls these into a custom email message and fires it out to the dev team.

I'd like to possibly do away with this task and simply include this added information into the normal TeamCity notification flow.

As I understand this, this would require me extending the notification system through the use of one or more plugins. Is there a "Hello World" version of how to go about this?

thanks,
Karl

4 comments
Comment actions Permalink

We have also been looking for something suitable to find around.
This is our solution to access the env.EMailPathToVersion parameters.

<#global bodyHtml>
<div>
  <div>
    Build <b>${project.fullName?html} :: ${buildType.name?html}</b> <a href='${link.buildResultsLink}'><@common.short_build_info build/></a> successful
    ${var.buildShortStatusDescription}
  </div>
  <div><@resp.buildTypeInvestigation buildType true/></div>
  <@common.build_agent build/>
  <div>
 <b>Buildresultate:</b> <a href='${build.parametersProvider.all['env.EMailPathToVersion']}'>${build.parametersProvider.all['env.EMailPathToVersion']}</a>
  </div>
  <@common.build_comment build/>
  <br>
  <@common.build_changes var.changesBean/>
  <@common.compilation_errors var.compilationBean/>
  <@common.test_errors var.failedTestsBean/>
  <@common.footerHtml/>
</div>
</#global>

I hope this helps.

0
Comment actions Permalink

Hi Mar99,
I guess I wasn't too far off then. This is the approach I hoping for, but wasn't aware of the parametersProviders service. Thanks for the hint, I'll give this another try with your supplied syntax example.

So to be clear, if I wanted to use a TC environment variable in my template, it would be like this:

My Custom Value: ${build.parametersProvider.all['env.MyCustomValue']}

I've got that right?

0
Comment actions Permalink

Yes, that should work. This should also work for other parameters (system and configuration).

I also found a second version in my tests (and now forgotten) to display a parameter in the notification. With the above posted variant I managed to also display parameters which are changed during builds. With the forgotten option, only the value of the parameter at the beginning of the build was always shown. That was not what I needed.

0
Comment actions Permalink

Thanks again, works like a champ!

0

Please sign in to leave a comment.