2016-11-25 36 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()方法。 –

相關問題