52

I want to get the build status in TFS (whether it is succeeded or failed). Which classes and methods can be used for this purpose?

CJBS
  • 15,147
  • 6
  • 86
  • 135

9 Answers9

99

You can run Build Notifications, which is similar to CC Tray in that it will continually give you the status of all builds that you're interested in following. To launch the tool, go to...

All Programs-->Microsoft Visual Studio 2010-->Team Foundation Server Tools-->Build Notifications

Click on the Options button to subscribe to whichever builds are on your server. This will now show up in your system tray with a green check box or red X to indicate the status of the builds you've selected.

Pattrick King
  • 1,172
  • 8
  • 13
  • 4
    +1 for moving from CC.net to TFS 3 years ago and not knowing that was there until now! Thanks! – Tom Morgan May 30 '12 at 13:45
  • Yes, I was using a free tool called "TFS Commit Monitor" , but glad to know this is built in. I just enabled it with VS 2012 , thx – Tom Stickel Jun 13 '13 at 21:33
  • @TomMorgan I modified cctray to also be able to listen to and queue tfs builds =) https://github.com/ImaginaryDevelopment/CruiseControl.NET – Maslow Jun 04 '14 at 15:00
  • 2
    For TFS 2015 and vNext builds, see [No build notifications with VS 2015?](http://stackoverflow.com/questions/32776840/no-build-notifications-with-vs-2015/35595760#35595760) – alex Feb 26 '16 at 21:47
  • The path has changed a little for VS2017 : C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\Common7\IDE\CommonExtensions\Microsoft\TeamFoundation\Team Explorer\BuildNotificationApp.exe – JJP Jun 01 '17 at 08:39
37

In Visual Studio 2013 with TFS 2013, you have email alerts from TFS and a Build Notification system tray tool: http://msdn.microsoft.com/en-us/library/ms181725.aspx

However, it usually doesn't show up in the Windows 8 Start screen, even with a search. So, run it manually in most installations from here:

C:\Program Files (x86)\Microsoft Visual Studio 12.0\Common7\IDE\BuildNotificationApp.exe

tmgirvin
  • 1,487
  • 11
  • 8
5

The TFS API is mostly documented on MSDN under the Visual Studio SDK: http://msdn.microsoft.com/library/bb130146, however the build APIs are in a different location (in the TFS documentation): http://msdn.microsoft.com/library/cc339575.

These are the same assemblies that tf.exe and Team Explorer (etc.) use.

Richard
  • 106,783
  • 21
  • 203
  • 265
4

If you just want the alert (not programmatically): You can right-click on the project in the Team Explorer and select Project Alerts.

GvS
  • 52,015
  • 16
  • 101
  • 139
  • Does this still work? In VS2013 the Team Explorer Builds page lists builds and build definitions. I can't see a _Project Alerts_ option on any context menu. – Richard Ev Feb 02 '16 at 10:33
3

You can use AnyStatus to monitor both XAML and vNext builds and lots of other monitors such as Windows Services, HTTP, TCP/IP, Ping, GitHub, Other CI/CD tools, Performance Counters and more.

Disclaimer: I am the author of AnyStatus

Alon Amsalem
  • 187
  • 1
  • 13
  • And this works for vNext builds too, unlike the included "Build Notifications" tool, which only works for XAML-based builds. – CJBS Jan 18 '18 at 17:34
  • Note: there's also a standalone version which doesn't require Visual Studio to be installed. – Alon Amsalem Feb 14 '19 at 14:42
2

To enable build notification e-mail alerts, in Team Explorer:

If you are not already connected to the team project that you want to work in, then connect to the team project.

Choose Home, and then choose Settings.

On the Settings page, under Team Project, choose Project Alerts. Select one or more alert events.

In the Send My Alerts To box, choose Edit and enter the email address of each person who should receive the alerts. Use semicolons to separate multiple email addresses.

more details, see : https://msdn.microsoft.com/en-us/library/ms181725.aspx

Ema.H
  • 2,862
  • 3
  • 28
  • 41
2

I just discovered CatLight which just works with little fuss. Never had any success with AnyStatus. CatLight sits in your tray and notifies you when builds succeed or fail.

NielW
  • 3,626
  • 1
  • 30
  • 38
2

Check out the MSBuildCommunityTasks library. It has a Mail task.

Import this into your build project to send the mails.

Gerrie Schenck
  • 22,148
  • 20
  • 68
  • 95
1

Under TFS 2008, you can right click on the TFS Project name (in Team Explorer) and select Project Alerts.

Then pick the A Build Completes alert and put your email address into the Send To field.

I think TFS 2005 also has this feature, but I can't rememeber. It's been awhile. ;)

NotMe
  • 87,343
  • 27
  • 171
  • 245