I'm using PowerShell to create work items in Azure DevOps.
The item is created and there is a new item ID showing in PowerShell:
How do I get this ID to use in the next command to update this work item?
Thank you!
I'm using PowerShell to create work items in Azure DevOps.
The item is created and there is a new item ID showing in PowerShell:
How do I get this ID to use in the next command to update this work item?
Thank you!
In order to get any field from the returns command you need to use --query.
From the docs:
The Azure CLI uses the --query argument to execute a JMESPath query on the results of commands. JMESPath is a query language for JSON, giving you the ability to select and modify data from CLI output. Queries are executed on the JSON output before any display formatting.
More info here.
Usage:
$WorkitemID = az boards work-item create --title "test" --type "Issue" --organization https://dev.azure.com/XXX --project YYYY --query id
output:
Write-Output $WorkitemID
4857
Later, just use $WorkitemID variable and pass it to any az command you want.