resources.webhooks.webhook definition (2024)

  • Article

A webhook resource enables you to integrate your pipeline with an external service to automate the workflow.

webhooks:- webhook: string # Required as first property. Name of the webhook. connection: string # Required. Name of the connection. In case of offline webhook this will be the type of Incoming Webhook otherwise it will be the type of the webhook extension. type: string # Name of the webhook extension. Leave this empty if it is an offline webhook. filters: [ filter ] # List of trigger filters.

Properties

webhook string. Required as first property.
Name of the webhook. Acceptable values: [-_A-Za-z0-9]*.

connection string. Required.
Name of the connection. In case of offline webhook this will be the type of Incoming Webhook otherwise it will be the type of the webhook extension.

type string.
Name of the webhook extension. Leave this empty if it is an offline webhook.

Examples

Basic example

You can define your pipeline as follows.

resources: webhooks: - webhook: WebHook connection: IncomingWHsteps: - script: echo ${{ parameters.WebHook.resource.message.title }}

To trigger your pipeline using the webhook, you need to make a POST request to https://dev.azure.com/<org_name>/_apis/public/distributedtask/webhooks/<webhook_connection_name>?api-version=6.0-preview. This endpoint is publicly available, and no authorization is needed. The request should have the following body.

{ "resource": { "message": { "title": "Hello, world!", "subtitle": "I'm using WebHooks!" } }}

When you access data from the webhook's request body, be mindful that it may lead to incorrect YAML. For example, if in the previous pipeline, your step reads - script: echo ${{ parameters.WebHook.resource.message }}, and you trigger the pipeline via a webhook, the pipeline doesn't run. This is because in the process of replacing ${{ parameters.WebHook.resource.message.title }} with message, which contains the following JSON, the generated YAML becomes invalid.

{ "title": "Hello, world!", "subtitle": "I'm using WebHooks!"}

Because the generated YAML becomes invalid, no pipeline run is queued in response.

Prevent unauthorized pipeline runs

Webhooks allow anyone to trigger your pipeline, as long as they know the names of your organization and webhook service connection.

You can prevent unauthorized pipeline runs by defining a secret when creating an Incoming Webhook service connection. You need to also specify the name of HTTP header that contains the SHA-1 checksum of the webhook's body.

To verify that an incoming webhook REST API call is authorized, Azure Pipelines computes the SHA-1 checksum of the request's body using the secret as key. It then compares it to the checksum passed in the request header. This way, the caller proves they know the secret.

Let's look at an example. Say you configured an Incoming Webhook service connection named IncomingWH, specified the secret is secret, and that the checksum is sent in the HTTP header named X-WH-Checksum. Imagine you have a pipeline that defines a Webhook resource.

Say you want to trigger the pipeline using the following request body:

{"resource":{"message":{"title":"Hello, world!","subtitle":"I'm using WebHooks!"}}}

To do this, you need to make a POST request to https://dev.azure.com/<org_name>/_apis/public/distributedtask/webhooks/IncomingWH?api-version=6.0-preview and add the X-WH-Checksum header with the value of 750D33212D3AD4932CC390819050734831A0A94F. You do not need to specify any username & password or any other type of authentication information.

Azure Pipelines will independently compute the SHA-1 checksum of the body using secret as key and will generate the same 750D33212D3AD4932CC390819050734831A0A94F value. Since the values match, the call is authorized, and pipeline queueing proceeds.

You compute the value of the X-WH-Checksum header, in pseudocode, as SHA1(secret).ComputeHash(requestBody). You can use .NET's System.Security.Cryptography.HMACSHA1 class for this purpose.

To prevent validation failures due to new lines or whitespaces, we recommend you send the body in a minimized form. That is, send

{"resource":{"message":{"title":"Hello, world!","subtitle":"I'm using WebHooks!"}}}

instead of

{ "resource": { "message": { "title": "Hello, world!", "subtitle": "I'm using WebHooks!" } }}

Even though the two JSON objects above represent the same object, they generate different SHA-1 checksums. This is because SHA-1 is computed on their string representation, which is different.

See also

resources.webhooks.webhook definition (2024)
Top Articles
How to Find Trust Wallet Recovery Phrase (& Change It)
Can I transfer crypto I buy through Venmo to other accounts?
Katie Pavlich Bikini Photos
Gamevault Agent
Hocus Pocus Showtimes Near Harkins Theatres Yuma Palms 14
Free Atm For Emerald Card Near Me
Craigslist Mexico Cancun
Hendersonville (Tennessee) – Travel guide at Wikivoyage
Doby's Funeral Home Obituaries
Vardis Olive Garden (Georgioupolis, Kreta) ✈️ inkl. Flug buchen
Select Truck Greensboro
Things To Do In Atlanta Tomorrow Night
Non Sequitur
How To Cut Eelgrass Grounded
Pac Man Deviantart
Alexander Funeral Home Gallatin Obituaries
Craigslist In Flagstaff
Shasta County Most Wanted 2022
Energy Healing Conference Utah
Testberichte zu E-Bikes & Fahrrädern von PROPHETE.
Aaa Saugus Ma Appointment
Geometry Review Quiz 5 Answer Key
Walgreens Alma School And Dynamite
Bible Gateway passage: Revelation 3 - New Living Translation
Yisd Home Access Center
Home
Shadbase Get Out Of Jail
Gina Wilson Angle Addition Postulate
Celina Powell Lil Meech Video: A Controversial Encounter Shakes Social Media - Video Reddit Trend
Walmart Pharmacy Near Me Open
A Christmas Horse - Alison Senxation
Ou Football Brainiacs
Access a Shared Resource | Computing for Arts + Sciences
Pixel Combat Unblocked
Cvs Sport Physicals
Mercedes W204 Belt Diagram
Rogold Extension
'Conan Exiles' 3.0 Guide: How To Unlock Spells And Sorcery
Teenbeautyfitness
Where Can I Cash A Huntington National Bank Check
Facebook Marketplace Marrero La
Nobodyhome.tv Reddit
Topos De Bolos Engraçados
Gregory (Five Nights at Freddy's)
Grand Valley State University Library Hours
Holzer Athena Portal
Hampton In And Suites Near Me
Stoughton Commuter Rail Schedule
Bedbathandbeyond Flemington Nj
Free Carnival-themed Google Slides & PowerPoint templates
Otter Bustr
Selly Medaline
Latest Posts
Article information

Author: Reed Wilderman

Last Updated:

Views: 6223

Rating: 4.1 / 5 (72 voted)

Reviews: 95% of readers found this page helpful

Author information

Name: Reed Wilderman

Birthday: 1992-06-14

Address: 998 Estell Village, Lake Oscarberg, SD 48713-6877

Phone: +21813267449721

Job: Technology Engineer

Hobby: Swimming, Do it yourself, Beekeeping, Lapidary, Cosplaying, Hiking, Graffiti

Introduction: My name is Reed Wilderman, I am a faithful, bright, lucky, adventurous, lively, rich, vast person who loves writing and wants to share my knowledge and understanding with you.