Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Eng]: Are there Azure Powershell commands that help create ADO items? #26956

Open
suneetsasidharan opened this issue Jan 2, 2025 · 1 comment
Labels
customer-reported feature-request This issue requires a new behavior in the product in order be resolved. needs-author-feedback More information is needed from author to address the issue.

Comments

@suneetsasidharan
Copy link

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()
@microsoft-github-policy-service microsoft-github-policy-service bot added customer-reported needs-triage This is a new issue that needs to be triaged to the appropriate team. labels Jan 2, 2025
@isra-fel
Copy link
Member

isra-fel commented Jan 8, 2025

@suneetsasidharan hi, thanks for reaching out.
Unfortunately there's no equivalent PS cmdlets for ADO - the closest thing is to use Invoke-RestMethod to call the APIs directly, but the downside is you need to deal with generic input/output models rather than the strong-typed models of other cmdlets. Here's an example to demonstrate that.

ADO team owns this VSTeam module to operate on ADO resources.

@isra-fel isra-fel added feature-request This issue requires a new behavior in the product in order be resolved. DevOps needs-author-feedback More information is needed from author to address the issue. and removed Engineering needs-triage This is a new issue that needs to be triaged to the appropriate team. DevOps labels Jan 9, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
customer-reported feature-request This issue requires a new behavior in the product in order be resolved. needs-author-feedback More information is needed from author to address the issue.
Projects
None yet
Development

No branches or pull requests

2 participants