Thursday, January 25, 2007

Team Build - Failure Email Alert - Make it Actually work for you

Long time no see. Yes I know it's my responsibility, and I don't even have a good excuse. So I hope you'll forgive me anyway - and let's go on.

Background

We have started at last to use Team Foundation instead of the "Die in Peace" Visual Source Safe. And as part of the move I decided to construct a CI (continuous integration) Build. I have followed "Continuous Integration Using Team Foundation Build" from MSDN, and I had a CI build in no time.

I even register myself to the Build Complete event, and created an Outlook rule to play a wav file (where I have recorded myself shouting "The build has failed, the build has failed"). But my roommate has made me shut it off.

Eventually you need to notify the developers of failing builds, and if shouting on the speakers doesn't works, I decided to forward the Email notification to all R&D Group List.

The Problem

But then I have started to get complaints from everyone on those emails. The developers tell me - "Why did I get this Email? I haven't even perform any check-in. So I couldn't be the one who caused the build to fail".

"They are right" I tell myself. If I keep sending those mails as suggested here, everyone will put a rule to send my email right into the garbage can. So what to do?

My Solution

The idea is to send failure emails only to the developers who performed a check-in. It is not a perfect solution - I know, It would be better to send the Email only to the spesific user who actually caused the failure - but at least it's a start.

Implementation

I have used Howard van Rooijen's Team Foundation Server Notification Web Services project template and implemented new functionality at the
Build Completion Endpoint. I check CompletionStatus, and if it "FAILED" I loop through Build's Changesets (as I learned here), collecting the users names. I construct a mail message based on TFS Mail template and just filled it with the correct data. The most important part, of course: I send this mail only to the users I have collected from the Changesets.

I hope to be able to upload the code soon.

Future Improvements

I plan to add some intelligence which will read the Build's log, and try to analyse who is the truly responsible for the failure.

Let me know what you think...

7 comments:

fpdeguzman1978 said...

hi Jon, i've found your blog and i'm looking on how to send email notification if the build only fails. maybe, you could help me out? thank you very much. have a nice day!

Jon said...

Hi fpdeguzman1978

If you'll give me any communication details to you (email, etc.) I will be glad to talk with you about it.

fpdeguzman1978 said...

Hi Jon,
sorry for the late reply. i was able to make the email notification works using bissubscribe utility. thank you very much. have a nice day!

fangfeich said...

Hi, Jon

Could you please share with me on what you have done on this?

I also need this function in our project.

My mail is fangfeich{ A T }gmail.com.

Thanks a lot in advance!

Justin said...

Do you have the source code for the solution to this problem? I too am trying to only send email notifications if the build status changes rather than everytime a build completes.

Mofoster said...

Hey Jon,

I would be interested to find out how to implemented Failure email alert in TFS team build. Would you be able to help me out?

my email is michael(dot)k(dot)wang(at)gmail(dot)com

Thanks

Jon said...

See this blog for the source:

http://readcommit.blogspot.com/2007/11/dept-payment-build-failure-email-alert.html