2

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 ?

Vadim Kotov
  • 8,084
  • 8
  • 48
  • 62

2 Answers2

5

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:

  1. Edit yer Pipeline
  2. Choose Triggers from the kabob menu
  3. Choose the YAML tab, see below
  4. Notice the default branch field; save

enter image description here

Also, yes the error referring to webHookId is the WebHook Name in the Incoming WebHook in Services Connections. Yay consistent naming.

multidynamic
  • 804
  • 8
  • 8
1

Based on my test, I could reproduce this issue.

enter image description here

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.

enter image description here

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.

Kevin Lu-MSFT
  • 20,786
  • 3
  • 19
  • 28
  • HI Kevin, thx for your answer. Do you mean that the value in "Webhook name" is NOT the one which should be used ? Which value do you mean ? To check the url is not possible due to I get the error I mentioned. – Frank Baumfalk May 24 '21 at 05:20
  • Yes. the webhook name could be incorrect. You need to confirm the webhook name (set in webhook request url). You can also check the webhook name in service connection(incoming webhook). From you curl command, you are using the value in Yaml Pipeline(webhook parameter). – Kevin Lu-MSFT May 24 '21 at 05:24
  • 2
    But this is the correct webhook name. The problem seems to be the default branch for the pipeline. It is only "Listeing" on that branch (pipeline branch not default repo branch). – Frank Baumfalk May 25 '21 at 06:02
  • @FrankBaumfalk. Thanks for your feedback. You could add an answer to share your solution, this will be helpful to other users.. – Kevin Lu-MSFT May 25 '21 at 06:06