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...