Search code examples
azure-devopsazure-repos

Link Azure Repo pull request retrospectively to work item


I've created a couple of small pull requests in Azure Repos. However, I forgot to link them to the relevant work items, so the pull requests have failed their checks. It looks like it should be easy to retrospectively link a pull request to a work item but it's not working for me.

On the taskboard I have a user story, Id 200258, with a sub-task, Id 214388:

Taskboard with user story and sub-task

When I attempt to link the pull request to a work item, however, it only shows a few work items in the Work items dropdown list:

Pull request Work items dropdown list

and if I enter the Id I want to find, it can't find it:

Unable to find work item 214388

The work item I want to find actually flashes up in the dropdown list momentarily, before the No items found message appears.

Is there any way to link the pull request to a work item that doesn't appear in the Work item dropdown list?


Solution

  • I would suggest you have a test with the Azure DevOps CLI az repos pr work-item add to Link one or more work items to a pull request.

    Here is a sample PowerShell script for your reference.

    $orgName = "YourADOOrgName"
    $env:AZURE_DEVOPS_EXT_PAT = "xxxxxx"
    $prId = 106
    
    az repos pr work-item add --id $prId --work-items 2347 2348 --org https://dev.azure.com/$orgName
    

    Image