Pages

Sunday, February 5, 2017

TFS Continuous Integration Walk Through Part 3 - Notifications

ci-logoThis 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.

2017-01-31_114324

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.

2017-01-31_114911

Send a test email.

2017-01-31_115054
2017-01-31_115205

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.

2017-01-31_123851

Select the CI Console Sample project. Click "View the project administration page"

2017-01-31_124017

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.

2017-01-31_124245

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".

2017-03-07_120812

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.

2017-03-07_121236

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.

2017-03-07_121630

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.

2017-01-31_124659

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;
        }
    }

2017-01-31_125046

Next Part: TFS Continuous Integration Walk Through Part 4a - Filtering Tests

No comments:

Post a Comment