How to subscribe to checkins not under a particular path
Nick Kirchem, who works on the TFS web access team, recently answered a question on how email subscriptions on checkin alerts. The question was, how do I subscribe to checkin alerts not under a particular folder?
Here’s how to do it.
bissubscribe /eventType CheckinEvent /address firstname.lastname@example.org /deliveryType EmailHtml /server http://myserver:8080/tfs/DefaultCollection "’Artifacts/Artifact[@ArtifactType=\"VersionedItem\"][not(starts-with(translate(@ServerItem, \"ABCDEFGHIJKLMNOPQRSTUVWXYZ\", \"abcdefghijklmnopqrstuvwxyz\"), \"$/devdiv/feature/build/qa\"))]’ <> null"
Let’s break it down.
- /eventType – Here we want CheckinEvent. There are others. Rather than list them, I’d recommend the Alerts Explorer that is part of the Team Foundation Server Power Tools. You can use it to discover more, as each different type has different things you can filter on.
- /address – The email address to use.
- /deliveryType – We want HTML-formatted email.
- /server – Here I’ve used the URL to the default collection on a TFS 2010 server. You’ll need to edit it to match the server and collection you need to use.
- expression – The expression is somewhat hard to read.
- The path we want to filter out is listed last, which $/devdiv/feature/build/qa in this case. You must use lowercase for your path.
- The translate XPath function is used to normalize the casing of the server path to be all lower case. This is important because XPath is case sensitive.
- The starts-with XPath function tests to see if the path is one we are interested in (in this case to filter out).
- The not XPath function inverts the test to see if it is not under the path we want to filter out.
- The quotation marks are escaped so that they can be inside quotation marks on the Windows command prompt.
Nick has also written a feature for TFS 11 to allow you to edit alerts inside the product through the web interface. An early version of it is in the TFS 11 CTP release that came out in concert with the Windows’ //build conference. Here’s a screen shot of it. Note that you can only see it in the UI if you enable email in the TFS Administration Console. Since then he’s made it easier to use and made it so that you can administer other user alerts, if you are an administrator.