检索VSTS / TFS构建任务名称列表

时间:2017-07-20 14:51:55

标签: tfs azure-devops tfsbuild azure-pipelines azure-pipelines-build-task

我需要从VSTS / TFS构建中检索构建任务名称列表。是否有内置的方法/库可以支持这个?

我已经注意到(如下面的示例)我们可以在发布中检索它。

import ReleaseClient = require("ReleaseManagement/Core/RestClient");
var rc= ReleaseClient.getClient(); 

release.environments.forEach(function (env) { 
    rc.getTasks(VSS.getWebContext().project.id, release.id, env.id).then(function(taskList){
    ...............
    ......Some code here
    });
}

1 个答案:

答案 0 :(得分:1)

documentation未显示直接函数调用以检索任务。但是,有BuildDefinition的合同,其中包含build属性,该属性是BuildDefinitionStep的数组,每个属性都有一个task属性,其中包含类似的内容任务的名称和输入。

getDefinition()函数应该为您提供可以使用的构建定义。

import RestClient = require("TFS/Build/RestClient");

// Get an instance of the client
var client = RestClient.getClient();
var myDefinition client.getDefinition(1234);