2016-11-25 27 views
0

我需要在VSTS构建任务输入PickList中显示“区域路径”,以便我可以从构建任务中检索用户选择的“区域路径”值,并将其设置在构建任务生成的工作项中。现有的VSTS API有可能吗?如果是的话如何做到这一点?如何在VSTS构建任务输入PickList中显示“区域路径”?

我认为这是在“实用工具”中的“复制文件”任务部分完成的。 enter image description here

在此先感谢。

+0

您可以定义sourceDefinitions以调用服务(例如REST API)以获取必要的数据并将数据绑定到dataSourceBindings中的相应选取列表。但是没有找到获得当前团队项目URL的方式?你能让用户指定团队项目的URL吗? –

+0

相关链接:https://github.com/Microsoft/vsts-tasks/issues/667 https://github.com/Microsoft/vsts-tasks/blob/master/Tasks/AzureAppServiceManage/task.json –

+0

@ starain- MSFT:我不能让用户输入项目名称,也无法使用VSTS凭据指定单独的终端来获取此数据。 (例如,您发送的示例链接) 谢谢。 – Bandara

回答

1

是的。您可以在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响应,你当有更多的儿童区域时,必须增加更多的投入。

+0

谢谢埃迪,这正是我一直在寻找的。 – Bandara

+0

是可以通过vso-node-api得到这个吗? – Bandara

+0

@Bandara是的,在WorkItemTrackingApi中使用getClassificationNode()方法。 –

相关问题