We use TFS 2010 for our work item tracking, source control, and build services. Beta 2, which is the currently released version of TFS & Visual Studio 2010, is nice and a very strong upgrade for those using 2008. I’ve spent a lot of time getting familiar with TFS, a lot more than in the past, and I’ve found a few things that threw me off and I will share them with you as time permits.
A key foundation of our escalation process is the ability to do alerting as items are introduced into the system, or modified, or lastly moved to a new state. We use email for our alerting and I’ve found a little quirk that seems to be “well known” (by the TFS product group) but maybe not to the world as I discovered. We used several stock queries that we already have built and stored in TFS as the basis for our alert queries.
Turns out, this didn’t work…So here goes some guidance from the pain & sweat that I went through to get it working.
Pre-Req for using Alerting
Prior to using email alerting, you are required to run TFS using a service account. The service account should be a email-enabled (in our case, Exchange mailbox) so that it can successfully send email in your organization. To setup your alerts in TFS 2010, you do the following:
- Open the Team Foundation Server Administrator’s Console (TFS 2010 only)
- Click Application Tier
- Click Change Alert Settings
- Enter your SMTP server account & mailbox-enabled user account
Testing Service Account Email
I recently asked one of my resident TFS experts to help me during this process of troubleshooting alerts & email. I asked him how one might could troubleshoot that Email alerting has been setup correctly in TFS. I was surprised that he wasn’t exactly sure what I meant so I realized that it wasn’t a common question. In my case, I didn’t know whether my alerting problem was email alert configuration setup incorrectly or whether it was the query evaluator so I wanted to “test” email.
Server-side testing for TFS Email
The first steps to try is to get out of TFS and validate that you can successfully, from your TFS application server, connect to your email server and send an email. Let’s walk through this…
- Add the Telnet Client on your Server using Server Manager
- Open an elevated CMD prompt
- Type telnet “mail server FQDN” 25 (without quotes)
- Depending on your email configuration for your environment, you can “Auth” or use anonymous (do what fits your environment)
- Follow the instructions outlined in this article using section titled “Use Telnet on Port 25 to test SMTP Communication”
Ahh, this failed – what now!
Before you freak out, don’t worry. Wait… you already freaked so don’t throw your keyboard as there might be a logical explanation for this. The one thing that I see again & again with administrators or Developers is they forget that Windows Server 2008 & above ships with the Windows Firewall enabled. The typical issue that occurs is that a firewall is blocking the connection out to your SMTP server. This can also be the problem in locked down network environments so ensure you have enabled SMTP in your network firewall.
To enable SMTP for the Windows Firewall in Server 2008, do the following:
- Open the Windows Firewall via Start –> Run –> firewall.cpl
- In the left hand pane, click Advanced settings
- Click Change Settings
- Highlight Outbound Rules
- Under Outbound Rules in the Actions pane, click New Rule
- Select Port and click Next
- In the textbox for Specific remote ports, enter 25
Finish the configuration by clicking Next and you will now have the firewall port opened for outbound SMTP. Unless you are using a Telnet Server, you shouldn’t need an inbound rule. Try your telnet test again from the steps above.
Successful Alerting using Email requires “Portfolio Project” rather than “Team Project”
The easiest approach for alerting is to start with a very, very simple query such as “when something is assigned to me.” This is a stock query that can be created by the system and is a good blueprint to what is a working query event to trigger the alert. Afterwards, you can then start making more complex alerts to meet your business needs.
In my case, I got the very simple stock to work with no problem. However, when I started creating an alert from a "[Blank Rule]” is when all #@## started happening and nothing was getting emailed. After doing an evaluation a bit between the working & non-working queries, I noticed that the stock alerts shipped with TFS all used “Portfolio Project” rather than “Team Project”. This was interesting to me so after making a slight modification to my alert the spam door was opened and it flooded my local mailbox. After investigating for a few days off & on, let’s just say this was the kind of spam I was happy to see!
To use email alerts in TFS 2010, you must have have the following in your query “Portfolio Project” = ‘TFS Project Name’. This will cause the event subscription service evaluator to work correctly and now you will start receiving your email.
Cool Troubleshooting Tip for Alerts
Grant Holliday’s blog provided some useful tracing capabilities for testing alerting. For purposes of this post, I just wanted to give a shout out to his post as it helped quite a bit in getting to the bottom of this issue. However, I did just use some old troubleshooting steps used by all of us – find one that works and then determine the difference. This technique works quite often!