As I understand, you can use a service connection to load options in a picklist in Azure custom task.
My questions is what kind of data can be loaded and from where exactly? Can I use it to access an Azure resource like a var group of a repo in Azure and get values from there to load to the pick list? Can you show an example of how to do it?
2
Answers
im not a expert but i can share my knowledge with you.
In Azure DevOps, using a service connection to populate options in a picklist within a custom task typically involves fetching data from external services or Azure resources. The ServiceConnection acts as a bridge, providing the necessary authentication and authorization to access resources.
what kind of data can be loaded and from where exactly?
You can load any data that the external service’s API can return, as long as it can be accessed via the service connection you configure.
Can I use it to access an Azure resource like a var group of a repo in Azure and get values from there to load to the pick list?
Accessing data from an Azure DevOps Variable Group or repository files directly to populate a picklist in a custom task isn’t straightforward because Azure DevOps does not directly support querying these types of Azure DevOps entities for picklist values without custom implementation. However, you can achieve this with a few additional steps involving the Azure DevOps Services REST API.
but i could not give you an example how the pracital thing works.
Hope this could help a bit.
If you have the source code of the extension, you can try to rewrite it:
You can try to call the Variablegroups related REST API in the JavaScript/TypeScript script file of the extension to get the data of variable groups. See "Call a REST API".
In the JavaScript/TypeScript script file, you can parse the JSON type response of the API call to get the data you require. If the data you require is a list/array, you can try to use an array variable to store the fetched data.
On the UI of the extension, you can add a combo control (see "Use the combo control"). Then you can pass the array variable to the combo control to fill in its drop-down list.