Search code examples
tfsazure-devops-extensions

JavaScript client API for task groups?


Most REST APIs of TFS/VSTS have a JavaScript client for extensions to use. Is there one for /_apis/distributedtask/taskgroups?

I've poked around the files under https://github.com/Microsoft/vss-web-extension-sdk/tree/master/typings , couldn't find one.

We're on TFS 2017u2.


Solution

  • Yes but it is still in preview. You can search keyword "taskgroup" in tfs.d.ts to get the detailed information.

    To use it in your extension:

    VSS.require(["VSS/Service", "TFS/DistributedTask/TaskAgentRestClient"], function (VSS_Service, TFS_TA_WebApi) {
    var taClient = VSS_Service.getCollectionClient(TFS_TA_WebApi.TaskAgentHttpClient);
    taClient.getTaskGroups("ProjectName").then(
        //...
    );
    });
    

    Remember to add vso.taskgroups scope in your extension. I'm not very sure about TFS2017 Update2, but I tested it on TFS2017 Update3, it works.