Include Build Log in "Build Failed" email

Answered

We're evaluating TeamCity 5.1.4 are are running into an issue using the email templates.  When a build fails, we would like the email to include a build log, so we're using the following line in "build_failed.ftl":

     ${build.buildProblems}

However, when the email is sent, we get the following error:

     [TEAMCITY TEMPLATE ERROR]

How should we call the buildProblems method?

We've also tried adding a section in "common.ftl"

     <#macro build_testMacro build>
       <#-- @ftlvariable name="build" type="jetbrains.buildServer.serverSide.SBuild" -->
       <div>${build.BuildProblems}</div>
     </#macro>

And then referencing that in "build_failed.ftl":


     <@common.build_testMacro build/>

But that doesn't work either.

Thank you,

-JP

5 comments
Comment actions Permalink

Hi,

Build.getBuildProblems() does not return the build log, it returns the list related problems, e.g. compilation error, out of memory error, etc.
You can try to use Build.getBuildLog() instead and iterate over the messages. That's the simplest way right now. Please vote for http://youtrack.jetbrains.net/issue/TW-7318

---
Maxim

0
Comment actions Permalink

Thank you Maxim.  I'm somewhat confused about how to use "Build.getBuildLog()" in the email template.

When I use it like ${build.buildLog}, I get the following message in the failed email:

jetbrains.buildServer.serverSide.impl.RunningBuildImpl$1@3587

Do I need to create a plugin to use "Build.getBuildLog()"? or is there another function I need to use in the template?

0
Comment actions Permalink

Hi,

Build.getBuildLog returns the BuildLog instance, which is exactly what you see (anonymous derived class, to be exact). What you need is to iterate over its messages using getMessages() method.
Please see http://javadoc.jetbrains.net/teamcity/openapi/current/jetbrains/buildServer/serverSide/buildLog/BuildLog.html


---
Maxim

0
Comment actions Permalink

Hi,

I would like to get the complete stack trace of the build error. Please let me know which method i should use?

Also, is there any way to get who broke the build?

Thanks,

Kavitha

0
Comment actions Permalink

Hi Kavitha,

Email attachement are still not supported. Please vote for the request https://youtrack.jetbrains.com/issue/TW-7318.
Currently you can include messages from the log or links to the build artifcts.

0

Please sign in to leave a comment.