最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

azure devops - Retrieve data from webhook payload - Stack Overflow

programmeradmin0浏览0评论

I am able to check several data from webhook payload, but cant other or even to see the full payload. So far I have added those variables which works as expected:

resources:
  [rest of the code]
  webhooks:
  - webhook: Coin
    connection: FromCoin
    filters:
      - path: resource.definition.name
        value: 'Coin'

variables:
  - name: buildNumber
    value: ${{ parameters.Coin.resource.buildNumber }}
  - name: sourceBranch
    value: ${{ parameters.Coin.resource.sourceBranch }}

I get such output:

Triggered by: CI-4-Coin Source Branch Name: refs/heads/release/2.0

For example, when I added:

  - name: targetBranch
    value: ${{ parameters.Coin.resource.targetBranch }}

It shows empty value under the targetBranch in ADO pipelines output. How to retrieve the full list of all available variables which I can consume from webhook payload in different org/project/pipeline in mine pipeline?

I am able to check several data from webhook payload, but cant other or even to see the full payload. So far I have added those variables which works as expected:

resources:
  [rest of the code]
  webhooks:
  - webhook: Coin
    connection: FromCoin
    filters:
      - path: resource.definition.name
        value: 'Coin'

variables:
  - name: buildNumber
    value: ${{ parameters.Coin.resource.buildNumber }}
  - name: sourceBranch
    value: ${{ parameters.Coin.resource.sourceBranch }}

I get such output:

Triggered by: CI-4-Coin Source Branch Name: refs/heads/release/2.0

For example, when I added:

  - name: targetBranch
    value: ${{ parameters.Coin.resource.targetBranch }}

It shows empty value under the targetBranch in ADO pipelines output. How to retrieve the full list of all available variables which I can consume from webhook payload in different org/project/pipeline in mine pipeline?

Share Improve this question edited Feb 5 at 19:32 scrapkowe asked Feb 5 at 13:33 scrapkowescrapkowe 815 bronze badges 0
Add a comment  | 

1 Answer 1

Reset to default 0

When referencing values from a webhook, the syntax is parameters.<WebhookAlias>.<JSONPath>.

To view the payload, you can use the convertToJson() function.

resources:
  webhooks:
  - webhook: myWebhookTrigger
    connection: IncomingWebhookServiceConnection

trigger: none

steps:
- pwsh: |
    write-host $env:payload
  env:
    payload: ${{ convertToJson( parameters.myWebhookTrigger ) }}

Given an example payload:

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

You would reference the values as:

  • parameters.myWebhookTrigger.resource.message.title
  • parameters.myWebhookTrigger.resource.message.subtitle
发布评论

评论列表(0)

  1. 暂无评论