Azure devops 如何获取拾取列表中的最新值
我正在尝试为Azure DevOps开发一个用于发布门的扩展/管道任务。不了解如何将最新值绑定到拾取列表,如下所示: 每次生成完成时,拾取列表都应将最新的生成Id作为所选值 这是我试过的代码片段, 这将创建一个拾取列表Azure devops 如何获取拾取列表中的最新值,azure-devops,Azure Devops,我正在尝试为Azure DevOps开发一个用于发布门的扩展/管道任务。不了解如何将最新值绑定到拾取列表,如下所示: 每次生成完成时,拾取列表都应将最新的生成Id作为所选值 这是我试过的代码片段, 这将创建一个拾取列表 { "name": "buildId", "type": "pickList", "label": "Artifact", "req
{
"name": "buildId",
"type": "pickList",
"label": "Artifact",
"required": true,
"defaultValue": "Latest",
"properties": {
"DisableManageLink": "True",
"EditableOptions": "True"
}
"helpMarkDown": "Build Artifacts"
},
这将绑定picklist的值
{
"target": "buildId",
"endpointId": "tfs:teamfoundation",
"endpointUrl": "{{endpoint.url}}/{{system.teamProject}}/_apis/build/builds?api-version=5.0",
"resultSelector": "jsonpath:$.value[*]",
"resultTemplate": "{ \"Value\" : \"{{{id}}}\", \"DisplayValue\" : \"{{{buildNumber}}} \" }"
}
请告诉我是否有任何方法可以实现此功能。恐怕您需要实现自己的代码方法,以将
最新的
值绑定到最新的buildid
例如在。根据字段buildVersionToDownload
的选定值(即最新版本)检索最新版本id:请参见以下内容:
buildVersionDownload
有三个选项
{
"name": "buildVersionToDownload",
"type": "pickList",
"label": "Build version to download",
"defaultValue": "latest",
"visibleRule": "buildType == specific",
"required": true,
"options": {
"latest": "Latest",
"latestFromBranch": "Latest from specific branch and specified Build Tags",
"specific": "Specific version"
}
}
如果将buildVersionDownload
值选择为specific
。然后需要在build
picklist中选择构建id
{
"name": "buildId",
"type": "pickList",
"label": "Build",
"defaultValue": "",
"required": true,
"visibleRule": "buildType == specific && buildVersionToDownload == specific",
"properties": {
"EditableOptions": "True",
"DisableManageLink": "True"
},
"helpMarkDown": "The build from which to download the artifacts"
}
buildVersionDownload
未绑定到数据源,仅绑定了buildId
:
{
"endpointId": "tfs:teamfoundation",
"target": "buildId",
"endpointUrl": "{{endpoint.url}}/{{project}}/_apis/build/builds?definitions={{definition}}&resultFilter=succeeded,partiallySucceeded&$top=200",
"resultSelector": "jsonpath:$.value[*]",
"parameters": {
"project": "$(project)",
"definition": "$(definition)"
},
"resultTemplate": "{ \"Value\" : \"{{{id}}}\", \"DisplayValue\" : \"{{{buildNumber}}}\" }"
}
有关更多信息,请参阅
如果选择buildVersionDownload
作为latest
。然后通过代码检索最新的构建id。参见代码示例
因此,在您的自定义任务中。当默认版本
为最新版本
时。您可以在代码方法中获取最新的生成id。当默认版本
不是最新版本
时。然后使工件可见,以从选取列表中选择构建id
{
"name": "buildId",
"type": "pickList",
"label": "Build",
"defaultValue": "",
"required": true,
"visibleRule": "buildType == specific && buildVersionToDownload == specific",
"properties": {
"EditableOptions": "True",
"DisableManageLink": "True"
},
"helpMarkDown": "The build from which to download the artifacts"
}