I've written a custom extension for Azure Devops which contains a custom Connected Service and Build task. I can use the Connected Service when configuring the task via the pipeline visual designer to select a service and then use that service to populate a picklist with data from my API.
However, how do I use the selected service when the task is executed. I need to access the service from the index.ts. The service tells me the endpoint and the API Key.
In the index.ts I can access the Guid of the service using something like the following code but can I use the Guid to get the service or it's details?
import tl = require('azure-pipelines-task-lib/task');
async function run() {
try {
const serviceString: string = tl.getInput('TestService', true);
if (serviceString == 'bad') {
tl.setResult(tl.TaskResult.Failed, 'Bad input was given');
return;
} ...
I've done lots of searching and reading (including the following articles) but haven't been able to find any examples.
https://learn.microsoft.com/en-us/azure/devops/extend/develop/add-build-task?view=azure-devops
https://learn.microsoft.com/en-us/azure/devops/extend/develop/service-endpoints?view=azure-devops