Skip to content

Instantly share code, notes, and snippets.

@kria
Created July 8, 2015 01:51
Show Gist options
  • Save kria/209047f536106f75a80f to your computer and use it in GitHub Desktop.
Save kria/209047f536106f75a80f to your computer and use it in GitHub Desktop.
TFS Push Subscriber
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;
}
}
}
@mediafreakch
Copy link

@kria Thank you, this worked perfectly!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment