TFS Continuous Integration Walk Through Part 3 - Notifications
2017-02-05 18:42
This is part of a series of walk throughs exploring CI in TFS, starting from the ground up. The entire series and source code are maintained at this BitBucket repository.
https://bitbucket.org/bladewolf55/tfs-ci-samples
Previous Part: TFS Continuous Integration Walk Through Part 2 - Create an Automated Build
That's great, right? It worked. But it's not going to help me if I don't know the build failed, and I'm not going to keep a TFS page open, watching it like a hawk. I want email alerts.
Note There used to be another option for notifications: the Build Notification application. It would show build failure notifications in the status tray. But that only works for XAML builds. There appears to be a third party utility that does the same thing for the modern builds: CatLight.
Configure SMTP for Email
References
Configure an SMTP server and customize email for alerts and feedback requests in TFS
TFS Email via Gmail Account <- He enables POP3, but you don't have to.
These steps assume you have administrative access to the administration console.
Open the Team Foundation Server Administration Console, select Application Tier, scroll down to and open Alert Settings.
In the Settings window, check Enable Email Alerts and configure your SMTP server settings. In my case, I used my Gmail account for testing.
Note There are challenges getting Gmail SMTP to work in TFS that are beyond the scope of this article. That means, it would take too much space to document it all.
Send a test email.
Configure TFS Alerts
References
Receive build notifications
Alerts are configured per team project. You can create project alerts from the Team Explorer > Settings, but below I show how to do it from the web site.
Open the main TFS page and click the Settings gear icon.
Select the CI Console Sample project. Click "View the project administration page"
Open the Alerts tab. Click the link under Create New Alert When... "A build fails". In the dialog, enter the Send To email address and click OK.
Configure Team TFS Alerts
Here's a simple configuration for build notifications. It assumes
- Not everyone on the team should be notified of build failures.
- There are two developers on the team who should receive notifications if any build fails.
Open the Overview tab in the Control panel. Click "New team".
Name the team something like "Build Failures". In the Permissions, leave as Contributers. Click Create Team.
Option
You could also allow anyone on the team to be a Build Admin by choosing that group.
Edit the team and add any desired team members.
Open the Alerts tab. Click the link under Create New Alert When... "A build fails". Rename as desired. The only difference from a personal alert is the Subscriber. In this case, "Build Failures" is the team who will receive the alert. Click OK.
Test Notification
Make a change of some kind to the source code (but that doesn't pass the tests!) and check in your changes. That will start a build. When the build fails, you should get an email.
Test Success
Let's finally get our test passing. Update the Greeting code, confirm the tests pass locally, then check in. You should not get an email alert, and you should see a successful build.
public class TextMan
{
public string Greeter(string value)
{
return "Hello, " + value;
}
}
Next Part: TFS Continuous Integration Walk Through Part 4a - Filtering Tests