1

I need to display the the "Area path" in a VSTS Build task input PickList, so that I can retrieve the user selected "Area path" value from my build task and set it in a work item generated by the build task. Is this possible with existing VSTS API? If so how to do this?

I think this is done in Copy Files task in Utilty section. enter image description here

Thanks in advance.

Community
  • 1
  • 1
Bandara
  • 780
  • 8
  • 29
  • You can definition sourceDefinitions to call service (e.g. REST API) to get necessary data and bind data to corresponding picklist in dataSourceBindings. But don't find the way to get current team project URL? Could you let user to specify team project URL? – starian chen-MSFT Nov 28 '16 at 03:35
  • Related links: https://github.com/Microsoft/vsts-tasks/issues/667 https://github.com/Microsoft/vsts-tasks/blob/master/Tasks/AzureAppServiceManage/task.json – starian chen-MSFT Nov 28 '16 at 05:11
  • @starain-MSFT: I can't let the user to enter the project name, Also cant specify a separate endpoint with VSTS credentials to get this data. (As in example link you sent) Thank you. – Bandara Nov 28 '16 at 06:46

1 Answers1

3

Yes, it is. You can add following section in task.josn file to achieve this:

  "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"
        }
    ],

And you will get the build task like this: enter image description here

However, due to data structure in the response of classification nodes api, you have to add more inputs when there are more level of child areas.

Eddie Chen - MSFT
  • 29,708
  • 2
  • 46
  • 60
  • Thank you Eddie, this is just what I was looking for. – Bandara Nov 29 '16 at 11:56
  • Is is possible to get this with vso-node-api? – Bandara Dec 07 '16 at 08:47
  • @Bandara Yes, use getClassificationNode() method in WorkItemTrackingApi. – Eddie Chen - MSFT Dec 07 '16 at 08:56
  • I'm getting following error when using getClassificationNode() [Error: Failed Request: Bad Request(400) - https://xxxxx.visualstudio.com/MyFirstProject/_apis/wit/classificationNodes/MyFirstProjectArea1Test] statusCode: 400 Following is the code sample, var areaPath = "MyFirstProject\Area1Test"; this.vstsWI.getClassificationNode(this.projName, wi.TreeStructureGroup.Areas, areaPath).then((nodex: wi.WorkItemClassificationNode) => { console.log(nodex); }).catch((e) => { console.error(e); }); – Bandara Dec 07 '16 at 12:45
  • @Bandara It seems that there is some issue with "TreeStructureGroup.Areas", the value is not applied in the rest api call. And you don't need to specify the root area in the area path. So use this code as a workaround for now: var areaPath = "Areas\\Area1Test"; this.vstsWI.getClassificationNode("MyFirstProject", null, areaPath).then((nodex: wi.WorkItemClassificationNode) => { console.log(nodex); }).catch((e) => { console.error(e); }); – Eddie Chen - MSFT Dec 08 '16 at 01:39
  • Is it possible with WorkItemTypes and States? Got types working but States are difficult.This is what I have now: {"target": "WorkItemType", "endpoint": "/$(system.teamProject)/_apis/wit/workItemTypes?api-version=1.0", "selector": "jsonpath:$.value[*].name", "keySelector": "jsonpath:$.value[*].name", "authKey": "tfs:teamfoundation" },{"target": "WorkItemState", "endpoint": "/$(system.teamProject)/_apis/wit/workItemTypes/$(WorkItemType)?api-version=1.0", "selector": "jsonpath:$.transitions.*[0].to", "keySelector": "jsonpath:$.transitions.*[0].to", "authKey": "tfs:teamfoundation" } – Marco van Kimmenade Feb 21 '17 at 18:21