Click here to Skip to main content
15,891,905 members
Articles / DevOps / TFS
Tip/Trick

Perform a custom action for Check-in event in Microsoft Team Foundation Server

Rate me:
Please Sign up or sign in to vote.
0.00/5 (No votes)
17 Mar 2013CPOL1 min read 19.3K   3  
Perform a custom action for Check-in event in Microsoft Team Foundation Server.

Introduction 

Microsoft Team Foundation Server is a very powerful and customizable tool user of version control. TFS 2005 is less stable when compared to TFS 2008.

Background 

Now I just faced a legitimate requirement..

When someone checks-in any file to the TFS, I need to get the list of files checked-in and perform a custom action based on that file(s) list. How do I do that??  I just need to extend the Microsoft TFS services. 

Using the code

TFS is nothing but a SQL Server database(s) and a Share Point Web Service. All actions to the TFS are done by calling webservices at http://yourservername:8080/…asmx. So what you need to do is listen for a particular event and then catch it and execute your code. 

BuildCompletionEvent NodesDeletedEvent
BuildStatusChangedEvent ProjectCreatedEvent
BranchMovedEvent ProjectDeletedEvent
NodeCreatedEvent CheckinEvent
NodePropertiesChangedEvent WorkItemChanged
NodeRenamedEvent

You can find the BisSubscribe.exe at –> C:\Program Files\Microsoft Visual Studio 2005 Team Foundation Server\TF Setup\.

TFS has a small interesting utility called BisSubscribe.exe, you can use this tool to subscribe to quite a few events in TFS. So, now i want to subscribe to the TFS Checkin-Event, and the command goes like this:

BisSubscribe.exe /server tfsserver01 /eventType CheckinEvent /deliveryType Email /address vinubaby1@gmail.com

This will create a subscription on the tfsserver01 server for CheckIn event and a email will be sent to vinubaby1@gmail.com, but this does not serve my requirement. I need a list of files checked-in the moment it is checked in. So, i just tweak the command like this.

BisSubscribe.exe /server tfsserver01 /eventType CheckinEvent /deliveryType Soap /address http://myserver:81/service.asmx

This command will create a subscription on tfsserver01 server for Checkin event and will invoke the Notify() method in the service.asmx webservice which i developed and published in http://myserver:81/

The webservice will have the Notify command with the following signature:

C#
[SoapDocumentMethod(Action = "http://Microsoft.VisualStudio.Bis/Notify", 
         RequestNamespace = http://Microsoft.VisualStudio.Bis)] 
[WebMethod] 
public void Notify(string eventXml) 
{ 
     //Write your custom code here 
     //Use eventXml to extract event related fields and their values 
}

The signature of the Notify function should be same as above.

Happy programming….. Enjoy.. 

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Web Developer
India India
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Comments and Discussions

 
-- There are no messages in this forum --