January 15, 2010

TFS 2008 Email Alerts and the Event Receiver

Filed under: TFS — Tags: , , , — Tim Lefler @ 11:30 am

Team Foundation Server (TFS) is a collection of services including version control, work item tracking, and an EventService service. The EventService exposes a set of events that, when fired, can perform actions such as sending e-mail or making a SOAP-based Web service call.

Email alerts can easily be configured on a per project basis using Team Explorer. Once connected to the Team Server, you’ll be able to access the Team menu on the main menu bar. If you select the menu item “Project Alerts” Visual Studio will open the Project Alerts dialog, which allows you to create e-mail subscriptions for the major events associated with a particular project.

Email Alerts for a Partucular Project

TFS will format the body of the message HTML or plain.  Multiple Email addresses can be configured by separating them with a semi-colon.  Email formating is controlled XSLT transforms located on the TFS server in the “C:\Program Files\Microsoft Visual Studio 2008 Team Foundation Server\Web Services\Services\v1.0\Transforms” directory.  It transforms the Event XML in to HTML or TEXT.

What if you want want to perform more extensive actions after an event is fired?  The TFS EventService is designed to extensible in that TFS events can be received by your own SOAP service which can then execute code in response to a particualr event.   There can be multiple services subscribed to an Event.  Below is a list of the common Events and the TFS Service associated with them.

Service Event
Version Control CheckInEvent
Team Build BuildCompletionEvent2
Team Build BuildStatusChangeEvent
Team Build BuildCompletionEvent
Common Structure Service ProjectCreatedEvent
Common Structure Service ProjectDeletedEvent

To create a subscription for an custom SOAP service for an event you use the BisSubscribe.exe command-line tool installed with TFS at “C:\Program Files\Microsoft Visual Studio 2008 Team Foundation Server\TF Setup”.

With BisSubscribe.exe you subscribe and unsubscribe from Server wide TFS Events.

Parameter Command Description
eventType Subscribe Name of the event.
filter Subscribe Filter expression. (not real sure on this one)
address Subscribe E-mail address or SOAP Web method URL  for the subscriber.
server Subscribe/Unsubscribe Team Foundation Server name.
tag Subscribe A field to use later to identify this subscription. (optional)
deliveryType Subscribe Delivery type: EmailHtml, EmailPlaintext, or SOAP.
id Unsubscribe Integer ID for the subscription to be deleted when unsubscribing.

Here are a couple of example using BisSubscribe:

To subscribe to Email notifications for the CheckinEvent for the entire server:

bissubscribe.exe /eventType CheckinEvent /address tim@someplace.com /deliveryType EmailHtml /server tfsserver

When Executed the output is this:

TF50001:  Created or found an existing subscription. 
The subscription ID is 5.

To unsubscribe to the Email notification event:

bissubscribe.exe unsubscribe /id 5 /server tfsserver

To subscribe a SOAP Service to the CheckInEvent for the entire server:

bissubscribe /eventType CheckinEvent /address http://localhost/SOAP_WebMethod/ /deliveryType Soap /server tfsserver

No Comments »

No comments yet.

RSS feed for comments on this post. TrackBack URL

Leave a comment

Powered by WordPress