根据 Azure Devops 中的文件路径类型动态填充选择列表?

Populate picklist dynamically based on filepath type in 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"
   }
 }

开箱即用的任务是开源的,大家可以通过repository to get some ideas of the patterns they use. Here is an example from the Download Build Artifacts task看看。构建定义取决于定义的项目。

{
        "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}}}\"}"
    },