How to Subscribe to TFS Alerts

Microsoft Team Foundation Server (TFS) contains a collection of services including version control, work item tracking, and the EventService service. EventService exposes a set of events that performs actions such as sending e-mail or a SOAP-based Web service call.

In this blog, I’ll examine TFS capabilities to create and manage subscriptions. While I will be using Visual Studio 2008 and TFS 2008, most of this column applies equally to TFS 2005.

Built In Alerts

Alerts are notifications in e-mail when certain events occur in your team project. You can subscribe to alerts for yourself or for others, and can select to receive alert messages in either HTML or Plain Text format. However, Team Explorer has 4 different built-in alerts:

Project Alerts

Using TFS Exposed Events

Alert subscriptions are stored on the server by team project, and you can add different alerts for each team project that you have permission to open. If you want to get notified for all new workitems, regardless of who they get assigned to, you will want a custom subscription. 

There are a couple of techniques you can use to achieve this.

BisSubscribe

First option is to create alert with the BisSubscribe tool that is on the TFS at C:\Program Files\Microsoft Visual Studio 2008 Team Foundation Server\TF Setup. Note that this tool is also available as a part of the Visual Studio Team Server (VSTS ) SDK, which is, in turn, a part of the larger Visual Studio SDK.

There is a ChangeType with each WorkItemChangedEvent, set to either “Change” or “New”.  In the filter expression below, only new changes will generate emails.

BisSubscribe.exe /eventType WorkItemChangedEvent /deliveryType EmailHtml /server <server name> /address <email address> /filter “PortfolioProject = ‘<project>’ AND ChangeType = ‘New’ ”

Parameter

Command

Notes

eventType

Subscribe

The name of the event. Case sensitive.

filter

Subscribe

A filter expression. Default is none.

address

Subscribe

The e-mail address or Web method URL for the subscriber.

server

Subscribe/Unsubscribe

The Team Foundation Server name.

tag

Subscribe

A field to use later to identify this subscription. Default is none.

deliveryType

Subscribe

Indicates the preferred message delivery type: EmailHtml, EmailPlaintext, or SOAP. Default is SOAP.

id

Unsubscribe

The integer ID for the subscription to be deleted when unsubscribing.

Team Foundation Server Event Subscription Tool

This tool for subscribing to events on a Team Foundation Server is based on the bissubscribe.exe tool, but have user interface. It is deployable to client workstations, whereas bissubscribe.exe only exists on the Team Foundation Server. It is very easy to use and with a couple of clicks you can create subscription (see screenshot).

Event Subscription Tool

List of supported events:

  • CheckInEvent
  • BranchMovedEvent
  • BuilsStatusChangedEvent
  • CommonStructureChangedEvent
  • DataChangedEvent
  • IdentityChangedEvent
  • NodePropertiesChangedEvent
  • NodeCreatedREvent
  • NodeRenamedEvent
  • NodeDeletedEvent
  • ProjectCreated Event
  • ProjectDeletedEvent
  • WorkItemChangedEvent

Precondition

Precondition for TFS to be able to send emails is to configure Team Foundation Server to use an existing SMTP server to send e-mail alerts. Users can configure alerts for various projects, work item, and build event notifications.

You can change the e-mail address by using the emailAddress parameter of the ChangeAccount Command or by manually editing the Services Web.Config file. However, to change the SMTP server, you must manually edit the Services Web.Config file.

The content of Team Foundation Server alert e-mails is not customizable. The content of the e-mails is automatically generated from the TeamFoundation.xsl file. Modifying this file is not recommended. If you do modify the contents of this file, be sure to thoroughly test your modifications. Incorrect modifications of this file can result in the failure of Team Foundation Server e-mail alerts and the inability to view Team Foundation work items, changesets, or files in a Web browser.

Required Permissions

To perform this procedure, you must be a member of the Administrators group on the Team Foundation application-tier server.

To define or change the SMTP server

  1. On the application-tier server for Team Foundation, locate the installation directory for the application tier.
  2. Open the Web Services directory, and then open the Services subdirectory.
  3. Open the Web.Config file, and locate the element.
  4. Update the element by typing the fully qualified domain name of the SMTP server

To define or change the sender e-mail address for e-mail alerts

  1. On the application-tier server for Team Foundation, locate the installation directory for the application tier.
  2. Open the Web Services directory, and then open the Services subdirectory.
  3. In a text or XML editor, open the Web.Config file, and locate the element.
  4. Update the element by typing the e-mail address that is associated with the service account (for example, Domain/TFSService) that is used for the application pool identity for Team Foundation.
  5. Save and close the file.

You must close and restart the Web services application for Team Foundation before your changes will take effect.

Tags:

Leave a Reply