如何显示"区域路径"在VSTS构建任务输入PickList?

时间:2016-11-25 09:01:18

标签: tfs azure-devops azure-pipelines azure-pipelines-build-task azure-devops-rest-api

我需要显示"区域路径"在VSTS Build任务中输入PickList,这样我就可以检索用户选择的"区域路径"来自构建任务的值,并将其设置在构建任务生成的工作项中。现有的VSTS API可以实现吗?如果是这样怎么做?

我认为这是在Utilty部分的Copy Files任务中完成的。 enter image description here

提前致谢。

1 个答案:

答案 0 :(得分:3)

是的,确实如此。您可以在task.josn文件中添加以下部分来实现此目的:

  "inputs": [
    {
      "name": "rootArea",
      "type": "pickList",
      "label": "rootArea",
      "defaultValue": "",
      "required": false,
      "helpMarkDown": "Select the root area.",
      "properties": {
                "DisableManageLink": "True"
            }   
    },
    {
      "name": "childArea",
      "type": "pickList",
      "label": "childArea",
      "defaultValue": "",
      "required": false,
      "helpMarkDown": "Select the child area.",
      "properties": {
                "DisableManageLink": "True"
            }   
    }
  ],
  "sourceDefinitions": [
        {
            "target": "rootArea",
            "endpoint": "/$(system.teamProject)/_apis/wit/classificationNodes/areas?$depth=2&api-version=1.0",
            "selector": "jsonpath:$.name",
            "keySelector": "jsonpath:$.name",
                "authKey": "tfs:teamfoundation"
        },
        {
            "target": "childArea",
            "endpoint": "/$(system.teamProject)/_apis/wit/classificationNodes/areas?$depth=2&api-version=1.0",
            "selector": "jsonpath:$.children[*].name",
            "keySelector": "jsonpath:$.children[*].name",
                "authKey": "tfs:teamfoundation"
        }
    ],

您将获得如下构建任务: enter image description here

但是,由于classification nodes api的响应中的数据结构,当有更多级别的子区域时,您必须添加更多输入。