'Incoming webhook trigger for Azure Devops pipeline : "Cannot find webhook for the given webHookId"
I try to setup a incoming webhook in a project to trigger a yaml pipeline. Setup service connection with incoming webhook. Added yaml snippet to pipeline like this:
resources:
webhooks:
- webhook: testtrigger ### Webhook alias
connection: testconnection ### Incoming webhook service connection
When calling the url via curl : curl -X POST 'https://dev.azure.com/<my org>/_apis/public/distributedtask/webhooks/testtrigger?api-version=6.0-preview' -d '{ "tags": {} }' -H "Content-Type: application/json"
, I always get the error message :
{"$id":"1","innerException":null,"message":"Cannot find webhook for the given webHookId testtrigger. Try enabling CD trigger for this artifact.","typeName":"Microsoft.TeamFoundation.DistributedTask.Pipelines.Artifacts.WebHooks.WebHookException, Microsoft.TeamFoundation.DistributedTask.Orchestration.Server","typeKey":"WebHookException","errorCode":0,"eventId":3000}
Tried with different names on triggers/connection but nothing worked. Any ideas what I am missing ?
Solution 1:[1]
Based on my test, I could reproduce this issue.
The root cause of this issue is that you are using the incorrect webhook name.
To find the correct webhook name, you could navigate to Project Settings -> Service Connection -> testconnection incoming webhook.
Or you could go to the target Webhook and check the request url:
https://dev.azure.com/<ADO Organization>/_apis/public/distributedtask/webhooks/<WebHook Name>?api-version=6.0-preview
The testtrigger
in yaml pipeline is the name of the webhook resource. This is a custom name instead of the correct webhook name.
Solution 2:[2]
Echoing @FrankBaumfalk's comment, you need to ensure the pipeline's default branch is the same as the one that youre developing on. (You may be like me, developing and testing this yaml on a branch of the same repo it is built for.)
To indicate your default branch:
- Edit yer Pipeline
- Choose Triggers from the kabob menu
- Choose the YAML tab, see below ?
- Notice the default branch field; save
Also, yes the error referring to webHookId
is the WebHook Name
in the Incoming WebHook in Services Connections. Yay consistent naming.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | Kevin Lu-MSFT |
Solution 2 | multidynamic |