0
votes

Overview: I try to trigger an Azure DevOps 2020 Pipeline (YAML) in the event that a WorkItem of a specific type is created. So my idea I had was to create a connection between "WorkItem" -> Service Hook of Type "Web Hook" -> Service Connection of Type "Incoming Webhook" -> resource:webhook triggers the Pipeline in YAML.

My problem now is, that I could create the serviceendpoint by GUI or by API, but the documentation and the created endpoint does not make sense for me. I am running my server on-premise and the endpoint I got looks like this:

{"count":1,"value":[{"data":{},"id":"1babbef7-1edb-4b01-bf18-b6e3c309caae","name":"TestIncomingWebhook","type":"incomingwebhook","url":"https://dev.azure.com", ...

The url does not make sense to me.

I can alter the url if I use the REST API to create the endpoint by using this format

POST https://{instance}/{collection}/{project}/_apis/serviceendpoint/endpoints

as described in Microsoft Azure API Documentation.

Questions:

  1. Why is the url that the service connection gets pointed to https://dev.azure.com while I am running on-premise from a server on a totally different url? Would that be the url I have to POST to trigger the ServiceConnection?
  2. What must be the correct URL-Format for my local Server? Where should I point that URL to?
  3. How can I trigger the Service Connection from curl? Do I have to use GET with a lot of parameters or POST with a JSON payload?

I would appreciate if someone could help me out on this. Perhaps someone even got a full solution on how to trigger pipelines on workitem events. I searched a lot but could not find a solution, yet.

Thanks, Peter.

I created the WebHook and ServiceConnection from the GUI like this:

My real problem is, that I got no feedback what the correct ServiceHook URL is. I have no idea where to point my WebHook.

Addition: The correct URL for accessing the Incoming Webhook Service Endpoint in Azure DevOps is https://{instance}/{Collection name}/_apis/public/distributedtask/webhooks/{Service Connection name}?api-version=6.0-preview

1

1 Answers

0
votes
  1. This should be related to your machine settings, you could share the detail steps here

  2. Since you are using Azure DevOps Server 2020, the url format for your local Server should be https://{instance}. You could open Azure DevOps Server Administration Console to check it.

  3. It will trigger the webhook via the event you selected.

You could refer to this ticket for more details.

In addition, you could try this Logic Apps then create flow to trigger build when specific type is created

Update1

  1. Create Service connection Incoming WebHook, eg. Web Hooks name is HookTests and Service connection name is TestHook

enter image description here

  1. Create Web Hooks and enter the URL https://{instance}/{Collection name}/_apis/public/distributedtask/webhooks/{Web Hook name eg. HookTests}?api-version=6.0-preview

  2. Create YAML build and add service connection resources in the yaml pipeline see below:

    resources: webhooks: - webhook: MyWebhookTrigger
    connection: {Service connection name, eg.TestHook}

Above steps actually do below things:

New workitem is created-->automatically Trigger Azure pipeline.

In addition, we could also add task power shell and call REST API to trigger another pipeline.

enter image description here