Using Azure Devops pipeline and webhook to trigger it, i can not get payload content

484 Views Asked by At

I'm trying to get the payload content coming from the webhook that trigger the pipeline when a work item is updated.

I have a powershell Task to try to get the content, for example, when a work item is updated, i want to get the System.AreaPath that is in the WorkItem and available in the payload.

trigger:
  none
pool:
  name: SYNCCHR

resources:
  webhooks:
    - webhook: GETPAYLOAD          
      connection: GETPAYLOAD_CON 

steps:
- task: PowerShell@2
  inputs:
    targetType: 'inline'
    script: |
      Write-Host "${{ parameters.GETPAYLOAD.resource.workItemId }}"
      Write-Host "${{ parameters.GETPAYLOAD.resource.revision.rev }}"
      Write-Host '${{ parameters.GETPAYLOAD.resource.revision.fields.System.AreaPath }}'

i don't find a way to get the System.Area value. parameters.GETPAYLOAD is a yaml expression related withe the parameters variable, it is gobal variable built-in in the yaml pipeline in Devops.

The fact the property System.AreaPath contains a dot in the name does not help with yaml syntax !

The payload is containing this kind of json :

payload content

I tried many time different syntax, triggering the pipeline via the update of work item but i can not obtain the content of properties under revision or fields nodes.

The goal is to be able to obtain in powershell task any property in the payload.

1

There are 1 best solutions below

0
David BRU On

i found finally the way to obtain the data concerning System.AreaPath:

the syntax is

for the workitem.updated event :
'"${{ parameters.GETPAYLOAD.resource.revision.fields['System.AreaPath'] }}"'
for the workitem.created event :
'"${{ parameters.GETPAYLOAD.resource.fields['System.AreaPath'] }}"'