parautenbach / TeamCity-HipChat-Notifier

TeamCity HipChat Notifier for sending build server notifications to HipChat.
Other
59 stars 31 forks source link

${durationOfTests} is always 0 #55

Closed npaufler closed 9 years ago

npaufler commented 9 years ago

After updating to 0.9.0, I tried to add the ${durationOfTests} macro to my Hipchat notifications. I'm finding that it is always returning 0 as the time period though, regardless of the actual runtime of the job.

Thanks

parautenbach commented 9 years ago

Could you please send me the output of the log, after enabling debug logging? This will show me the actual value provided by the build server.

npaufler commented 9 years ago

2015-07-10 18:53:52,720 - DEBUG - Adding standard build statistics 2015-07-10 18:53:52,721 - DEBUG - Number of tests: 0 2015-07-10 18:53:52,721 - DEBUG - Number of passed tests: 0 2015-07-10 18:53:52,722 - DEBUG - Number of failed tests: 0 2015-07-10 18:53:52,722 - DEBUG - Number of new failed tests: 0 2015-07-10 18:53:52,722 - DEBUG - Number of ignored tests: 0 2015-07-10 18:53:52,722 - DEBUG - Tests duration: 0 2015-07-10 18:53:52,722 - DEBUG - Adding discovered build statistics 2015-07-10 18:53:52,782 - DEBUG - buildStageDuration:firstStepPreparation: 83.000000 2015-07-10 18:53:52,782 - DEBUG - buildStageDuration:buildFinishing: 44.000000 2015-07-10 18:53:52,782 - DEBUG - buildStageDuration:artifactsPublishing: 364.000000 2015-07-10 18:53:52,782 - DEBUG - BuildDuration: 2368065 2015-07-10 18:53:52,782 - DEBUG - buildStageDuration:sourcesUpdate: 12364.000000 2015-07-10 18:53:52,782 - DEBUG - buildStageDuration:buildStepRUNNER_10: 2354766.000000 2015-07-10 18:53:52,782 - DEBUG - BuildDurationNetTime: 2368032

Would be the relevant bit, I believe.

All of my build steps are commandline. Perhaps that's the issue? Would there be any way to expose the BuildDurationNetTime in the same way DurationOfTests is?

Thanks

On Thu, Jul 9, 2015 at 2:51 PM, Pieter Rautenbach notifications@github.com wrote:

Could you please send me the output of the log, after enabling debug logging https://github.com/parautenbach/TeamCity-HipChat-Notifier#developers? This will show me the actual value provided by the build server.

— Reply to this email directly or view it on GitHub https://github.com/parautenbach/TeamCity-HipChat-Notifier/issues/55#issuecomment-120140777 .

Nicholas Paufler System Administrator Clio - Practice Management Simplified 1-888-858-2546 nicholas.paufler@clio.com www.clio.com | blog http://www.clio.com/blog | twitter http://www.twitter.com/goclio | facebook http://www.facebook.com/goclio

npaufler commented 9 years ago

Happy to provide any additional info you need.

parautenbach commented 9 years ago

Which version of TeamCity are you running? I'm running plugin v0.9.0 and TeamCity v9.0.2 (build 32195).

Template:

Build <a href="${serverUrl}/viewType.html?buildTypeId=${buildTypeId}">${fullName}</a> <#if hasBranch>on branch <b>${branch}</b></#if> was successful. It was build number <a href="${serverUrl}/viewLog.html?buildId=${buildId}">#${buildNumber}</a> and was triggered by ${triggeredBy} (${durationOfTests}). <#if hasContributors>Contributors: ${contributors}.</#if> <img src="${emoticonUrl}">

Log:

2015-08-02 18:17:35,189 - DEBUG - Adding standard build statistics 
2015-08-02 18:17:35,190 - DEBUG -   Number of tests: 0 
2015-08-02 18:17:35,190 - DEBUG -   Number of passed tests: 0 
2015-08-02 18:17:35,190 - DEBUG -   Number of failed tests: 0 
2015-08-02 18:17:35,190 - DEBUG -   Number of new failed tests: 0 
2015-08-02 18:17:35,190 - DEBUG -   Number of ignored tests: 0 
2015-08-02 18:17:35,190 - DEBUG -   Tests duration: 0 

Result: screen shot 2015-08-02 at 18 19 36

parautenbach commented 9 years ago

This seems to be a bug with the TeamCity Open API (in specifically TC v0.9.0). This is how the build duration value is added to the template:

BuildStatistics statistics = build.getFullStatistics();
...
templateMap.put(HipChatNotificationMessageTemplates.Parameters.DURATION_OF_TESTS, statistics.getTotalDuration());

where BuildStatistics is defined by the API.

There is a documented alternative: All build statistics found by the plugin are available to the templates using a stats. prefix. E.g., this template works:

Build <a href="${serverUrl}/viewType.html?buildTypeId=${buildTypeId}">${fullName}</a> <#if hasBranch>on branch <b>${branch}</b></#if> was successful. It was build number <a href="${serverUrl}/viewLog.html?buildId=${buildId}">#${buildNumber}</a> and was triggered by ${triggeredBy} (duration: ${.data_model["stats.BuildDuration"] / 1000}s). <#if hasContributors>Contributors: ${contributors}.</#if> <img src="${emoticonUrl}">

where the applicable bit is ${.data_model["stats.BuildDuration"] (you'll see this in your log that you posted here under discovered stats).

screen shot 2015-08-02 at 18 45 31

npaufler commented 9 years ago

Confirmed, that does what we need. Thank you kindly.

parautenbach commented 9 years ago

You're welcome.