Email Notification: Include more information about triggers.
When getting email notifications I use
<#if build.triggeredBy.triggeredByUser>(triggered by ${build.triggeredBy.user.descriptiveName?html})</#if>
where it gives me the name of the user that triggered the build. This line is of course from the ftl files.
On the teamcity server I see more information such as time and other builds that may have triggered this build.
Question: Is there a way to have that information included in the email notification?
Thank you.
Please sign in to leave a comment.
Hello,
Yes, it can be included, but can be tricky.
Trigger time is simple, use getTriggeredDate() method:
http://javadoc.jetbrains.net/teamcity/openapi/current/jetbrains/buildServer/serverSide/TriggeredBy.html#getTriggeredDate()
Listing build dependencies will require to get a BuildPromotion instance:
http://javadoc.jetbrains.net/teamcity/openapi/current/jetbrains/buildServer/serverSide/BuildPromotionOwner.html#getBuildPromotion()
Having which you can get all dependencies:
http://javadoc.jetbrains.net/teamcity/openapi/current/jetbrains/buildServer/serverSide/BuildPromotion.html#getDependencies()
http://javadoc.jetbrains.net/teamcity/openapi/current/jetbrains/buildServer/serverSide/BuildPromotion.html#getDependedOnMe()
and etc.
I've tried
Triggered Date: ${build.triggeredBy.getTriggeredDate}
Triggered Date: ${project.getTriggeredDate}
Triggered Date: ${build.triggeredBy.getTriggeredDate()}
Triggered Date: ${project.getTriggeredDate()}
to get the date. But all of them give me a template error.
Hi,
Please try ${build.triggeredBy.triggeredDate}.
You can consult with the FreeMarker expressions here: http://freemarker.sourceforge.net/docs/dgui_template_exp.html
--
Maxim
I've consulted a bit of FreeMarkers guides but I'm not exactly sure what I'm supposed to be looking at.
Triggered date: ${build.triggeredBy.triggeredDate}
that line of code still yields a template error.
Hi!
It seems FreeMarker is more verbose than I thought =)
The doc says to add "?date" or "?time" to print the Date object:
http://freemarker.sourceforge.net/docs/ref_builtins_date.html#ref_builtin_date_datetype
Please try that.
--
Maxim