Following the provided documentation for the Azure Pipeline InvokeRESTAPI task, I am trying to use the callback feature. The waitForCompletion
argument must be true
, and the callback triggered as follows.
To signal completion, the external service should POST completion data to the following pipelines REST endpoint.
{planUri}/{projectId}/_apis/distributedtask/hubs/{hubName}/plans/{planId}/events?api-version=2.0-preview.1
**Request Body**
{ "name": "TaskCompleted", "taskId": "taskInstanceId", "jobId": "jobId", "result": "succeeded" }
My problem is that I was unable to find more information about the parameters to use in the endpoint above.
{planUri}/{projectId}/
the same as https://dev.azure.com/{organization}/{project}/
?hubName
and planId
?taskId
and jobId
are related to the Azure Pipeline that triggers the initial HTTP call, but how can one obtain them? I cannot seem to find them on the predefined variables list.This information does not seem to be available in the distributedtask API documentation.
I too was having a lot of difficulty tracking this down. Linked from the Invoke Rest API Task docs is a sample project with an image showing the headers and their values mapped from Azure Pipelines variables.
They are:
PlanUri: $(system.CollectionUri)
ProjectId: $(system.TeamProjectId)
HubName: $(system.HostType)
PlanId: $(system.PlanId)
JobId: $(system.JobId)
TimelineId: $(system.TimelineId)
TaskInstanceId: $(system.TaskInstanceId)
AuthToken: $(system.AccessToken)
I'm about to give it a go with the Invoke Azure Function Task which has the same callback parameters. Wish me luck...
EDIT Clearly I missed the bit in the docs where it shows that these values are set by default in the header:
#headers: '{Content-Type:application/json, PlanUrl: $(system.CollectionUri), ProjectId: $(system.TeamProjectId), HubName: $(system.HostType), PlanId: $(system.PlanId), JobId: $(system.JobId), TimelineId: $(system.TimelineId), TaskInstanceId: $(system.TaskInstanceId), AuthToken: $(system.AccessToken)}'