执行发行时,我们需要选择要部署的特定软件包版本(默认情况下为最新版本,但也可以是较旧的版本)。现在,该字段是一个简单的文本框,我们必须在其中手动指定版本,但这容易出错,因为用户基本上可以在其中放置所需的内容,并且每当将新版本推送到Feed时,我们都需要更新发布定义。是否可以通过某种方式在定义中配置变量以查看提要中软件包的特定版本,并将其显示为用户的下拉列表?
答案 0 :(得分:0)
默认情况下,没有任何方法可以执行此操作。您需要创建一个自定义构建任务并调用Feed API来实现。
例如,在自定义构建任务中添加以下部分:
"inputs": [
{
"name": "feedList",
"type": "pickList",
"label": "feedList",
"defaultValue": "",
"required": false,
"helpMarkDown": "Select the feed.",
"properties": {
"DisableManageLink": "True"
}
},
{
"name": "packageList",
"type": "pickList",
"label": "packageList",
"defaultValue": "",
"required": false,
"helpMarkDown": "Select the package.",
"properties": {
"DisableManageLink": "True"
}
},
{
"name": "versionList",
"type": "pickList",
"label": "versionList",
"defaultValue": "",
"required": false,
"helpMarkDown": "Select the version.",
"properties": {
"DisableManageLink": "True"
}
}
],
"dataSourceBindings": [
{
"target": "feedList",
"endpointId": "tfs:feed",
"endpointUrl": "{{endpoint.url}}/_apis/packaging/feeds",
"resultSelector": "jsonpath:$.value[*]",
"resultTemplate": "{ \"Value\" : \"{{{id}}}\", \"DisplayValue\" : \"{{{name}}}\" }"
},
{
"target": "packageList",
"endpointId": "tfs:feed",
"parameters": {
"feed": "$(feedList)"
},
"endpointUrl": "{{endpoint.url}}/_apis/packaging/feeds/{{{feed}}}/Packages",
"resultSelector": "jsonpath:$.value[*]",
"resultTemplate": "{ \"Value\" : \"{{{id}}}\", \"DisplayValue\" : \"{{{name}}}\" }"
},
{
"target": "versionList",
"endpointId": "tfs:feed",
"parameters": {
"feed": "$(feedList)",
"package": "$(packageList)"
},
"endpointUrl": "{{endpoint.url}}/_apis/packaging/feeds/{{{feed}}}/Packages/{{{package}}}/Versions",
"resultSelector": "jsonpath:$.value[*]",
"resultTemplate": "{ \"Value\" : \"{{{version}}}\", \"DisplayValue\" : \"{{{version}}}\" }"
}
],