I wanted to know how we can capture termination of a pipeline task in ADO in shellscript

99 Views Asked by At

I have a requirement to invoke a CURL command when a pipeline in ADO is cancelled. Can someone please let me know how i can capture cancelled status of an ADO pipeline and use that in a shellscript to invoke a CURL command.

1

There are 1 best solutions below

0
On BEST ANSWER

how i can capture cancelled status of an ADO pipeline and use that in a shellscript to invoke a CURL command.

You can get the execution result of the build pipeline through the rest api below:

https://dev.azure.com/{org}/{pro}/_apis/build/builds/{buildId}?api-version=5.1

Test in Postman:

enter image description here

Then you can write a script to get the pipeline result(e.g.$result = $response.result), determine whether the result is canceled, if it is, invoke a CURL command.