Created
July 8, 2015 01:51
-
-
Save kria/209047f536106f75a80f to your computer and use it in GitHub Desktop.
TFS Push Subscriber
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using Microsoft.TeamFoundation.Common; | |
using Microsoft.TeamFoundation.Framework.Server; | |
using Microsoft.TeamFoundation.Git.Server; | |
using System; | |
using System.Linq; | |
namespace PushSub | |
{ | |
public class PushSubscriber : ISubscriber | |
{ | |
public Type[] SubscribedTypes() | |
{ | |
return new Type[] { typeof(PushNotification) }; | |
} | |
public string Name | |
{ | |
get { return "PushSubscriber"; } | |
} | |
public SubscriberPriority Priority | |
{ | |
get { return SubscriberPriority.Normal; } | |
} | |
public EventNotificationStatus ProcessEvent(TeamFoundationRequestContext requestContext, NotificationType notificationType, | |
object notificationEventArgs, out int statusCode, out string statusMessage, out ExceptionPropertyCollection properties) | |
{ | |
statusCode = 0; | |
statusMessage = string.Empty; | |
properties = null; | |
if (notificationType == NotificationType.Notification) | |
{ | |
var push = notificationEventArgs as PushNotification; | |
if (push.RefUpdateResults.Any(r => r.Succeeded && r.Name.StartsWith("refs/tags"))) | |
{ | |
// one or more tags have been pushed, do stuff.. | |
} | |
} | |
return EventNotificationStatus.ActionPermitted; | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
@kria Thank you, this worked perfectly!