0

In a customized build task, how can I use http post/get method to get data from service running on a third server?

In a build task like below screenshot, I want to get populate the dropdown list from a third server. enter image description here

At this time, I can only populate the dropdown list from a static list in the task.json file like below:

"inputs": [

    {"name":"CompanyDepartments",



       "type":"pickList",



       "label":"Company Departments",



       "defaultValue":"",



       "required":true,



       "helpMarkDown":"",



       "groupName":"group1",



       "options":{



           "0":"Developers",



           "1":"Admin",



           "2":"Requirements"}



   },
Dan Zhang
  • 11
  • 1

1 Answers1

0

This could be achieved, you could define sourceDefinitions to call service (e.g. REST API) to get necessary data and bind data to corresponding picklist in dataSourceBindings.

Suggest doing the following:

  • Create a custom endpoint for relic service
  • Add a dataSource in the endpoint corresponding to the REST URL to query applications
  • Add a resultSelector within the dataSource to parse out the Name from each of the appName json element
  • Add an endpoint input to your task
  • Add a dataSourceBinding from your task that references the dataSource you defined in the endpoint

You can refer to how drop down for Azure storage accounts has been added to Azure File Copy task as an example:

https://github.com/Microsoft/vsts-tasks/blob/master/Tasks/AzureFileCopy/task.json

You could also take a look at this tutorial--Service Endpoints in VSTS: it shows how a build task which defines 2 properties: The service endpoint & a picklist which has values populated from the REST endpoint data source.

Some more threads to bind source for your reference:

PatrickLu-MSFT
  • 49,478
  • 5
  • 35
  • 62