Writing Filters for TFS Alerts – a exercise in frustration

My team recently began looking at possibly migrating to a new TFS configuration where we would enable several dev groups with related components/systems that previously had separate dev management systems and bring them into one team project.  One of the first things that we wanted to make sure was possible was the ability to get alerts for only check-ins directly in our section of the codebase and for all changes to workitems connected to our efforts.

I was familiar with bissubscribe.exe somewhat and knew that there was filtering capability so I began looking around.  I was amazed at how little documentation there is out there for working with VSEFL (Visual Studio Event Filtering Language).  I found some here and Clark Sell has some stuff here.  Clark references a link that say you will find everything you want to know and more at it about Eventing well I would have to disagree because there is not good documentation for VSEFL and how to use it effectively. 

Accentient has a list of Team System widgets and lists two for use in working with Events and Notifications (Alerts).  Naren’s tool hurt me to start with, but ended up helping me in the end.

Here is how it all worked out.

Check-In Subscription

This was the easy part – Buck Hodges had the answer in one of his blog posts and so I just took that and modified it with my path information and away we went – it all worked.

WorkItemChangedEvent

I thought this one was going to be likewise easy with Naren’s tool.  Unfortunately it doesn’t produce filter expressions that work with Bissubscribe.exe.  The way the command-line wants the single and double quotes is different than Naren generates and so I was getting invalid subscriptions created.  They were invalid because they didn’t have single quotes around the System.IterationPath string in part of the filter and without the quotes the filter just wouldn’t work.  It took quite a bit of playing to figure out how it should work, but in the end I ended up with a working bissubscribe.exe call to have a filter for only those workitems that fell under a certain Iteration Path which is how we are choosing to segment our subprojects within our Team Project.  Below is the final call with some of my specific info stripped out (like my email address!)

BisSubscribe.exe /eventType WorkItemChangedEvent /deliveryType EmailHtml /server someserver:8080 /address someemail@email.com /filter "PortfolioProject = 'FSM DSS' AND ("CoreFields/StringFields/Field[ReferenceName='System.IterationPath']/NewValue" MATCH '\FSM DSS\TSS.*' OR "CoreFields/StringFields/Field[ReferenceName='System.IterationPath']/OldValue" MATCH '\FSM DSS\TSS.*')"

Notice the before the double quotes at the start of the CoreFields… and then the before the close double quotes at the end – those were crucial – but I don’t know why – I suspect it is some escape at the command line that I should know – but it worked and perhaps someday I will look it up to try and understand it.  If you know please leave a comment explaining it to me!

I hope this helps someone somewhere such that they have an easier time figuring this out then I did

 

Advertisements
This entry was posted in Technology. Bookmark the permalink.

One Response to Writing Filters for TFS Alerts – a exercise in frustration

  1. Donald says:

    Command line parameters are parsed into (essentually) a string array. The double quote marks tell the command line parser that the following text until the next double quote is a single parameter even if it has white spaces in it. Because of this, you have to escape any double quotes inside the double quoted parameter, otherwise the command line parser finds the nested double quote and thinks it is the end of the parameter.hello.exe /do this and thatreturns four parameters, [/do], [this], [and] and [that].hello.exe /do "this and that"returns two parameters, [/do] and [this and that].hello.exe /do "this \"and\" that"returns two parameters, [/do] and [this "and" that].hello.exe /do "this "and" that"returns two parameters (because the interior quotes are concat’ed with the middle word making one string), [/do] and [this and that].hello.exe /do "this " and " that"returns four parameters [/do], [this ], [and], [ that].

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s