-
Notifications
You must be signed in to change notification settings - Fork 4.1k
Closed
Labels
customer-reportedfeature-requestThis issue requires a new behavior in the product in order be resolved.This issue requires a new behavior in the product in order be resolved.needs-author-feedbackMore information is needed from author to address the issue.More information is needed from author to address the issue.no-recent-activityThere has been no recent activity on this issue.There has been no recent activity on this issue.
Description
Description
We're using something like the following snippet for creating and auto linking a work item to a PR in the build pipeline. We're curious if there is a Azure Powershell command that achieves the same without adding "az" into the mix in the pipeline.
steps:
- powershell: |
Write-Host "Installing Azure CLI extensions..."
az extension add --name azure-devops
displayName: 'Install Azure CLI Extensions'
env:
AZURE_DEVOPS_EXT_PAT: $(System.AccessToken)
condition: always()
- powershell: |
Write-Host "Checking for associated work items..."
$workItems = az boards work-item relation list --id $(Build.BuildId) --query "[?rel=='System.LinkTypes.Hierarchy-Reverse'].target.id" -o tsv
if (-not $workItems) {
Write-Host "No associated work items found. Creating a new work item..."
$prTitle = az repos pr show --id $(System.PullRequest.PullRequestId) --query "title" -o tsv
$workItem = az boards work-item create --title "$prTitle" --type "Bug" --description "This work item was created because no work item was associated with build $(Build.BuildId)." --assigned-to "$(Build.RequestedFor)" --area "Outlook Web\Native Host" --query "id" -o tsv
Write-Host "Linking work item $workItem to the pull request..."
az repos pr work-item add --id $(System.PullRequest.PullRequestId) --work-items $workItem
} else {
Write-Host "Associated work items found: $workItems"
}
displayName: 'Check, Create, and Link Work Item'
env:
AZURE_DEVOPS_EXT_PAT: $(System.AccessToken)
condition: always()
Metadata
Metadata
Assignees
Labels
customer-reportedfeature-requestThis issue requires a new behavior in the product in order be resolved.This issue requires a new behavior in the product in order be resolved.needs-author-feedbackMore information is needed from author to address the issue.More information is needed from author to address the issue.no-recent-activityThere has been no recent activity on this issue.There has been no recent activity on this issue.