So you have setup your continuous integration and every time you are doing a checkin, a new automated build is launched on your build server. Nice !
You have also launched the Team Foundation Build Notification tool to have a small popup alert every time a build finishes and starts. Nice !
But you would like to go a bit further and receive a mail with the build result every time a build fails (or let's say do not succeed).
Use the TFS' alerts
The Team Foundation Server includes a powerful alert system, but by default, you cannot do so many things.
Use the Team Foundation Server Power Tools
If the Project Alerts does not allow so many things, the underlying alert system is very powerful. And you can use the Team Foundation Server Power Tools (http://visualstudiogallery.msdn.microsoft.com/c255a1e4-04ba-4f68-8f4e-cd473d6b971f) that allow a very fine control of the alerts.
You can then create a new rule like the following one :
Note that for the Send To field, you can either indicate a account name, or an email address. In the case of an account name, this correspond to an AD account, and you must have configured the email address of that person in the Active Directory.
How to customize the received email ?
All the alert process is based on XML and XSL and so you can customize the email you will received.
In the above windo, you have the Event field, corresponding to the alert type that will be raised. In our case, this correspond to the type BuildCompletionEvent2.
You can find in the folder C:\Program Files\Microsoft Team Foundation Server 2010\Application Tier\TFSJobAgent\Transforms all the XSL that are used to transform the XML into a nice HTML or plain text email. The XSL are named with the event type. So in our case, we are interesed in the two following files :
- BuildCompletionEvent2.xsl for HTML emails
- BuildCompletionEvent2.plaintextXsl for plain text emails
Now it's up to you to customize the XSL content to include for example your company logo.
Which fields are available to include in the XSL ?
It's nice to be able to customize the XSL to change its look, but it could be interesting also to include some more information.
So which are the information available ?
You can have access to the XSD in the TFS database.
Just run the following query in your TFS database :
select * from tbl_EventType
and you will see for each event type the available fields.
If you want to really see the XML and not the XSD, you can simply
- specify that your alert launch an plain text email
- replace the XSL by one that does give the XML like the following one
<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
<xsl:output method="xml" indent="yes"/>
<xsl:template match="@* | node()">
<xsl:apply-templates select="@* | node()"/>