azure-devops - 根据 Azure Devops 中的文件路径类型动态填充选项列表?
问题描述
在 Azure Devops 中,我正在使用构建任务构建一个扩展,其中输入选项列表字段依赖于另一个输入文件路径字段。当用户提供输入文件路径时,我想动态读取并使用新项目填充选项列表。我试图搜索和实施,但找不到方法。任何帮助或指导将不胜感激。我找到了下面的示例来帮助我获取静态值。
{
"name": "action",
"type": "pickList",
"label": "Action",
"defaultValue": "Publish",
"required": true,
"helpMarkDown": "Select the Action to perform",
"options": {
"Publish": "Publish Changes",
"Script": "Script Changes",
"DeployReport": "Generate Deployment Report"
}
}
解决方案
开箱即用的任务是开源的,因此您可以查看存储库以了解它们使用的模式。这是下载构建工件任务的示例。构建定义取决于定义的项目。
{
"name": "project",
"type": "pickList",
"label": "Project",
"defaultValue": "",
"required": true,
"visibleRule": "buildType == specific",
"properties": {
"EditableOptions": "True",
"DisableManageLink": "True"
},
"helpMarkDown": "The project from which to download the build artifacts"
},
{
"name": "definition",
"aliases": [
"pipeline"
],
"type": "pickList",
"label": "Build pipeline",
"defaultValue": "",
"required": true,
"visibleRule": "buildType == specific",
"properties": {
"EditableOptions": "True",
"DisableManageLink": "True",
"IsSearchable": "True"
},
"helpMarkDown": "Select the build pipeline name"
},
然后在 dataSourceBindings 部分相信它使用来自先前选择的目标作为参数输入。
"dataSourceBindings": [
{
"endpointId": "tfs:teamfoundation",
"target": "project",
"endpointUrl": "{{endpoint.url}}/_apis/projects?$skip={{skip}}&$top=1000",
"resultSelector": "jsonpath:$.value[?(@.state=='wellFormed')]",
"resultTemplate": "{ \"Value\" : \"{{{id}}}\", \"DisplayValue\" : \"{{{name}}}\" }",
"callbackContextTemplate": "{\"skip\": \"{{add skip 1000}}\"}",
"callbackRequiredTemplate": "{{isEqualNumber result.count 1000}}",
"initialContextTemplate": "{\"skip\": \"0\"}"
},
{
"endpointId": "tfs:teamfoundation",
"target": "definition",
"endpointUrl": "{{endpoint.url}}/{{project}}/_apis/build/definitions?api-version=3.0-preview&$top=500&continuationToken={{{continuationToken}}}&name=*{{name}}*&queryOrder=2",
"resultSelector": "jsonpath:$.value[?(@.quality=='definition')]",
"parameters": {
"project": "$(project)",
"name": "$(name)"
},
"resultTemplate": "{ \"Value\" : \"{{{id}}}\", \"DisplayValue\" : \"{{{name}}}\" }",
"callbackContextTemplate": "{\"continuationToken\" : \"{{{headers.x-ms-continuationtoken}}}\"}",
"callbackRequiredTemplate": "{{{#headers.x-ms-continuationtoken}}}true{{{/headers.x-ms-continuationtoken}}}",
"initialContextTemplate": "{\"continuationToken\" : \"{{{system.utcNow}}}\"}"
},
推荐阅读
- javascript - NPM 和 Eslint:这很混乱,这正常吗?
- java - 为什么我会收到 IndexOutOfBoundsException
- eclipse - Eclipse-PlatformFilter 文档
- actionscript-3 - 如何解决 AS3 中的图例错误#2025?
- javascript - 反应将导入名称作为道具传递并添加到图像 src
- java - 从 JDBC 中以批处理模式选择不同的实体
- html - 设置 gcloud apppot 域 - 找不到 URL 错误
- html - 为什么我的 Flexbox 在底部留下一个巨大的空隙?
- python - Golang 和 Python 执行 http 请求的方法的根本区别?
- android - 为 Android ARM 交叉编译 glibc - 配置错误