Get TFS associated work item of a checkin (not changeset)

Multi tool use
Multi tool use












0














I am creating a server side code review policy for TFS and I currently have it working for any checkin that runs through visual studio, But when someone trys to checkin through the Web UI it doesnt work.



The policy is looking for an associated work item on the checkin and then looks through that work item to confirm it meets specific requirements. I am able to get the associated work item from visual studio check in's via



public EventNotificationStatus ProcessEvent(IVssRequestContext requestContext, NotificationType notificationType, object notificationEventArgs, out int statusCode, out string statusMessage, out ExceptionPropertyCollection properties)
{
statusCode = 0;
statusMessage = string.Empty;
properties = new ExceptionPropertyCollection();

var checkinNotification = notificationEventArgs as CheckinNotification;
if (notificationType == NotificationType.DecisionPoint && notificationEventArgs is CheckinNotification)
{

bool isNullComment = false;
bool isCheckinContains = false;

var service = requestContext.GetService<ILocationService>();

TfsTeamProjectCollection tfsTeamProjectCollection = new TfsTeamProjectCollection(GetTfsUri(requestContext));

WorkItemStore workitemStore = tfsTeamProjectCollection.GetService<WorkItemStore>();

var changes = checkinNotification.GetSubmittedItems(requestContext);

isCheckinContains = changes.Any(change => change.ToUpper().Contains("$/"));
if (isCheckinContains)
{
isNullComment = string.IsNullOrEmpty(checkinNotification.Comment.ToString());

//Read all associated workitem id's
var assoWorkItems = checkinNotification.NotificationInfo.WorkItemInfo.Select(x => x.Id);
}
}
}


this however does not work with the web UI. The main difference I notice when running the code against Visual studio and the web UI is the request context refers to a very different URL.



Visual Studio Request context URL: http://localhost:8080/tfs/DefaultCollection/VersionControl/v5.0/repository.asmx



Web Ui request context: http://localhost:8080/tfs/DefaultCollection/_apis/tfvc/changesets



I believe I need to use a different namespace and methods to access the info inside the checkin using the web UI.



I have been trying to use the "Microsoft.VisualStudio.Services.WebApi" namespace to get data from the web UI, but I cannot find any info online on how to get info of a checkin that is trying to process










share|improve this question
























  • What do you mean "not a changeset"? Check in is an action that a user performs that creates a changeset. There's no entity called a "check in" that you can retrieve.
    – Daniel Mann
    Dec 27 '18 at 20:38
















0














I am creating a server side code review policy for TFS and I currently have it working for any checkin that runs through visual studio, But when someone trys to checkin through the Web UI it doesnt work.



The policy is looking for an associated work item on the checkin and then looks through that work item to confirm it meets specific requirements. I am able to get the associated work item from visual studio check in's via



public EventNotificationStatus ProcessEvent(IVssRequestContext requestContext, NotificationType notificationType, object notificationEventArgs, out int statusCode, out string statusMessage, out ExceptionPropertyCollection properties)
{
statusCode = 0;
statusMessage = string.Empty;
properties = new ExceptionPropertyCollection();

var checkinNotification = notificationEventArgs as CheckinNotification;
if (notificationType == NotificationType.DecisionPoint && notificationEventArgs is CheckinNotification)
{

bool isNullComment = false;
bool isCheckinContains = false;

var service = requestContext.GetService<ILocationService>();

TfsTeamProjectCollection tfsTeamProjectCollection = new TfsTeamProjectCollection(GetTfsUri(requestContext));

WorkItemStore workitemStore = tfsTeamProjectCollection.GetService<WorkItemStore>();

var changes = checkinNotification.GetSubmittedItems(requestContext);

isCheckinContains = changes.Any(change => change.ToUpper().Contains("$/"));
if (isCheckinContains)
{
isNullComment = string.IsNullOrEmpty(checkinNotification.Comment.ToString());

//Read all associated workitem id's
var assoWorkItems = checkinNotification.NotificationInfo.WorkItemInfo.Select(x => x.Id);
}
}
}


this however does not work with the web UI. The main difference I notice when running the code against Visual studio and the web UI is the request context refers to a very different URL.



Visual Studio Request context URL: http://localhost:8080/tfs/DefaultCollection/VersionControl/v5.0/repository.asmx



Web Ui request context: http://localhost:8080/tfs/DefaultCollection/_apis/tfvc/changesets



I believe I need to use a different namespace and methods to access the info inside the checkin using the web UI.



I have been trying to use the "Microsoft.VisualStudio.Services.WebApi" namespace to get data from the web UI, but I cannot find any info online on how to get info of a checkin that is trying to process










share|improve this question
























  • What do you mean "not a changeset"? Check in is an action that a user performs that creates a changeset. There's no entity called a "check in" that you can retrieve.
    – Daniel Mann
    Dec 27 '18 at 20:38














0












0








0







I am creating a server side code review policy for TFS and I currently have it working for any checkin that runs through visual studio, But when someone trys to checkin through the Web UI it doesnt work.



The policy is looking for an associated work item on the checkin and then looks through that work item to confirm it meets specific requirements. I am able to get the associated work item from visual studio check in's via



public EventNotificationStatus ProcessEvent(IVssRequestContext requestContext, NotificationType notificationType, object notificationEventArgs, out int statusCode, out string statusMessage, out ExceptionPropertyCollection properties)
{
statusCode = 0;
statusMessage = string.Empty;
properties = new ExceptionPropertyCollection();

var checkinNotification = notificationEventArgs as CheckinNotification;
if (notificationType == NotificationType.DecisionPoint && notificationEventArgs is CheckinNotification)
{

bool isNullComment = false;
bool isCheckinContains = false;

var service = requestContext.GetService<ILocationService>();

TfsTeamProjectCollection tfsTeamProjectCollection = new TfsTeamProjectCollection(GetTfsUri(requestContext));

WorkItemStore workitemStore = tfsTeamProjectCollection.GetService<WorkItemStore>();

var changes = checkinNotification.GetSubmittedItems(requestContext);

isCheckinContains = changes.Any(change => change.ToUpper().Contains("$/"));
if (isCheckinContains)
{
isNullComment = string.IsNullOrEmpty(checkinNotification.Comment.ToString());

//Read all associated workitem id's
var assoWorkItems = checkinNotification.NotificationInfo.WorkItemInfo.Select(x => x.Id);
}
}
}


this however does not work with the web UI. The main difference I notice when running the code against Visual studio and the web UI is the request context refers to a very different URL.



Visual Studio Request context URL: http://localhost:8080/tfs/DefaultCollection/VersionControl/v5.0/repository.asmx



Web Ui request context: http://localhost:8080/tfs/DefaultCollection/_apis/tfvc/changesets



I believe I need to use a different namespace and methods to access the info inside the checkin using the web UI.



I have been trying to use the "Microsoft.VisualStudio.Services.WebApi" namespace to get data from the web UI, but I cannot find any info online on how to get info of a checkin that is trying to process










share|improve this question















I am creating a server side code review policy for TFS and I currently have it working for any checkin that runs through visual studio, But when someone trys to checkin through the Web UI it doesnt work.



The policy is looking for an associated work item on the checkin and then looks through that work item to confirm it meets specific requirements. I am able to get the associated work item from visual studio check in's via



public EventNotificationStatus ProcessEvent(IVssRequestContext requestContext, NotificationType notificationType, object notificationEventArgs, out int statusCode, out string statusMessage, out ExceptionPropertyCollection properties)
{
statusCode = 0;
statusMessage = string.Empty;
properties = new ExceptionPropertyCollection();

var checkinNotification = notificationEventArgs as CheckinNotification;
if (notificationType == NotificationType.DecisionPoint && notificationEventArgs is CheckinNotification)
{

bool isNullComment = false;
bool isCheckinContains = false;

var service = requestContext.GetService<ILocationService>();

TfsTeamProjectCollection tfsTeamProjectCollection = new TfsTeamProjectCollection(GetTfsUri(requestContext));

WorkItemStore workitemStore = tfsTeamProjectCollection.GetService<WorkItemStore>();

var changes = checkinNotification.GetSubmittedItems(requestContext);

isCheckinContains = changes.Any(change => change.ToUpper().Contains("$/"));
if (isCheckinContains)
{
isNullComment = string.IsNullOrEmpty(checkinNotification.Comment.ToString());

//Read all associated workitem id's
var assoWorkItems = checkinNotification.NotificationInfo.WorkItemInfo.Select(x => x.Id);
}
}
}


this however does not work with the web UI. The main difference I notice when running the code against Visual studio and the web UI is the request context refers to a very different URL.



Visual Studio Request context URL: http://localhost:8080/tfs/DefaultCollection/VersionControl/v5.0/repository.asmx



Web Ui request context: http://localhost:8080/tfs/DefaultCollection/_apis/tfvc/changesets



I believe I need to use a different namespace and methods to access the info inside the checkin using the web UI.



I have been trying to use the "Microsoft.VisualStudio.Services.WebApi" namespace to get data from the web UI, but I cannot find any info online on how to get info of a checkin that is trying to process







c# visual-studio tfs tfvc






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Dec 27 '18 at 20:36









Daniel Mann

37.6k65885




37.6k65885










asked Dec 27 '18 at 16:43









Nick

64111




64111












  • What do you mean "not a changeset"? Check in is an action that a user performs that creates a changeset. There's no entity called a "check in" that you can retrieve.
    – Daniel Mann
    Dec 27 '18 at 20:38


















  • What do you mean "not a changeset"? Check in is an action that a user performs that creates a changeset. There's no entity called a "check in" that you can retrieve.
    – Daniel Mann
    Dec 27 '18 at 20:38
















What do you mean "not a changeset"? Check in is an action that a user performs that creates a changeset. There's no entity called a "check in" that you can retrieve.
– Daniel Mann
Dec 27 '18 at 20:38




What do you mean "not a changeset"? Check in is an action that a user performs that creates a changeset. There's no entity called a "check in" that you can retrieve.
– Daniel Mann
Dec 27 '18 at 20:38












1 Answer
1






active

oldest

votes


















0














The web editing experience uses a different set of APIs, as you've observed. Server-side policies apparently don't get processed when using the newer APIs, as server-side plugins are a supported-but-not-really-recommended-heading-toward-being-deprecated type of feature.



So basically, your policy doesn't apply to the web UI, and there's no way to make it. You can suggest that Microsoft add support by posting something on UserVoice, but that's about it.






share|improve this answer





















    Your Answer






    StackExchange.ifUsing("editor", function () {
    StackExchange.using("externalEditor", function () {
    StackExchange.using("snippets", function () {
    StackExchange.snippets.init();
    });
    });
    }, "code-snippets");

    StackExchange.ready(function() {
    var channelOptions = {
    tags: "".split(" "),
    id: "1"
    };
    initTagRenderer("".split(" "), "".split(" "), channelOptions);

    StackExchange.using("externalEditor", function() {
    // Have to fire editor after snippets, if snippets enabled
    if (StackExchange.settings.snippets.snippetsEnabled) {
    StackExchange.using("snippets", function() {
    createEditor();
    });
    }
    else {
    createEditor();
    }
    });

    function createEditor() {
    StackExchange.prepareEditor({
    heartbeatType: 'answer',
    autoActivateHeartbeat: false,
    convertImagesToLinks: true,
    noModals: true,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: 10,
    bindNavPrevention: true,
    postfix: "",
    imageUploader: {
    brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
    contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
    allowUrls: true
    },
    onDemand: true,
    discardSelector: ".discard-answer"
    ,immediatelyShowMarkdownHelp:true
    });


    }
    });














    draft saved

    draft discarded


















    StackExchange.ready(
    function () {
    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53948215%2fget-tfs-associated-work-item-of-a-checkin-not-changeset%23new-answer', 'question_page');
    }
    );

    Post as a guest















    Required, but never shown

























    1 Answer
    1






    active

    oldest

    votes








    1 Answer
    1






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes









    0














    The web editing experience uses a different set of APIs, as you've observed. Server-side policies apparently don't get processed when using the newer APIs, as server-side plugins are a supported-but-not-really-recommended-heading-toward-being-deprecated type of feature.



    So basically, your policy doesn't apply to the web UI, and there's no way to make it. You can suggest that Microsoft add support by posting something on UserVoice, but that's about it.






    share|improve this answer


























      0














      The web editing experience uses a different set of APIs, as you've observed. Server-side policies apparently don't get processed when using the newer APIs, as server-side plugins are a supported-but-not-really-recommended-heading-toward-being-deprecated type of feature.



      So basically, your policy doesn't apply to the web UI, and there's no way to make it. You can suggest that Microsoft add support by posting something on UserVoice, but that's about it.






      share|improve this answer
























        0












        0








        0






        The web editing experience uses a different set of APIs, as you've observed. Server-side policies apparently don't get processed when using the newer APIs, as server-side plugins are a supported-but-not-really-recommended-heading-toward-being-deprecated type of feature.



        So basically, your policy doesn't apply to the web UI, and there's no way to make it. You can suggest that Microsoft add support by posting something on UserVoice, but that's about it.






        share|improve this answer












        The web editing experience uses a different set of APIs, as you've observed. Server-side policies apparently don't get processed when using the newer APIs, as server-side plugins are a supported-but-not-really-recommended-heading-toward-being-deprecated type of feature.



        So basically, your policy doesn't apply to the web UI, and there's no way to make it. You can suggest that Microsoft add support by posting something on UserVoice, but that's about it.







        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered Dec 27 '18 at 20:40









        Daniel Mann

        37.6k65885




        37.6k65885






























            draft saved

            draft discarded




















































            Thanks for contributing an answer to Stack Overflow!


            • Please be sure to answer the question. Provide details and share your research!

            But avoid



            • Asking for help, clarification, or responding to other answers.

            • Making statements based on opinion; back them up with references or personal experience.


            To learn more, see our tips on writing great answers.





            Some of your past answers have not been well-received, and you're in danger of being blocked from answering.


            Please pay close attention to the following guidance:


            • Please be sure to answer the question. Provide details and share your research!

            But avoid



            • Asking for help, clarification, or responding to other answers.

            • Making statements based on opinion; back them up with references or personal experience.


            To learn more, see our tips on writing great answers.




            draft saved


            draft discarded














            StackExchange.ready(
            function () {
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53948215%2fget-tfs-associated-work-item-of-a-checkin-not-changeset%23new-answer', 'question_page');
            }
            );

            Post as a guest















            Required, but never shown





















































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown

































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown







            w9iXMB yaALoP 8lBP2gV806qfFd,8NZEiq5UcsSVDDWm41 l ABiwKaF1dIZTCwquoy
            GgY Rh,CtTo LWQ0dGZuQ8A8awGSmZkqEm7Df40raHeU5 jIwL6UfxI,mX,78sr1

            Popular posts from this blog

            Monofisismo

            Angular Downloading a file using contenturl with Basic Authentication

            Olmecas