How to trigger a webhook after azure pipeline run completes

97 Views Asked by At

I have an azure runbook that has some Python code. And this runbook needs to be triggered as soon as an azure pipeline runs successfully. Note: I cannot make changes to the pipeline steps or the pipeline. This should be done via configurations or some workarounds.

Our customers have 100s of pipelines/pipeline jobs, so changing the pipelines to 'add' one more step to trigger the webhook is not feasible.

2

There are 2 best solutions below

0
simon-pearson On BEST ANSWER

This could be achieved through the webhooks functionality natively offered by Azure DevOps, see: Webhooks with Azure DevOps - Azure DevOps | Microsoft Learn.

If the pipelines are YAML pipelines or classic build pipelines then you'll want to select the Build completed event type.

enter image description here

0
Kevin Lu-MSFT On

simon-pearson's method is correct.

We can use the Webhook in Azure DevOps Project Settings -> Service Hooks -> Webhook to run the Post method to trigger the Azure Runbook.

I would like to share more detailed steps about complete the process:

Step1: Create the Webhook in Azure Runbook. We can record the Webhook URL.

enter image description here

Step2: Navigate to Azure DevOps Project Settings -> Service Hooks -> Webhook. Then we can select the Trigger event: Build completed and patse the webhook URL to the URL Field.

enter image description here

Result:

When the Pipeline runs complete, it will trigger the service hook and trigger the Azure RunBook via the webhook.

Azure DevOps:

enter image description here

Azure Runbook job:

enter image description here