How to retrieve Azure work item deployment status

I am putting together a release report which includes the

  1. List of commits in the current release (ex:if the previous prod release was on 12/01 then I get the list of all commits since then)
  2. From the commits I get the work items associated with it using devops API
  3. Also list the files associated to each commit hash

All workitems are linked to commits and release pipeline deployment information as mentioned here: https://docs.microsoft.com/en-us/azure/devops/boards/work-items/work-item-deployments-control?view=azure-devops

I need the deployment information for each work item. How can this information be retrieved?


You have to make sure the build and release pipeline definitions are configured to associate work items during the whole CI/CD process.

The first step is to make sure every code change is associated with a work item. This will link the work items with commits, branches and Pull requests. You can accomplish that by enabling a build policy to check for linked work items.

You can achieve this by following the below steps:

  1. Click the Repositories and the Branches Menu in the Azure DevOps Portal . A screenshot of a cell phone Description automatically generated

  2. Locate in the branch list the one you are going to use to build from, typically that should be your master branch, and click the options icon. Select Branch policies. A screenshot of a cell phone Description automatically generated

  3. Check the option ”Check for linked work items”. Click Save changes. A screenshot of a social media post Description automatically generated

The next step is to enable the build definition to create links to all work items linked to associated changes when a build completes successfully.

  1. Select your build pipeline definition and click Edit on the top right corner of the page. A picture containing screenshot Description automatically generated

  2. In the Options Tab, enable the option “Automatically link new work in this build”. Click Save. A picture containing knife Description automatically generated

The last step is to configure the release pipeline to link those work items to the release when a stage is completed.

  1. Select your release pipeline definition and click Edit on the top right corner of the page. A screenshot of a cell phone Description automatically generated

  2. In the Options Tab, select the Integrations Section and enable the option “Report deployment status to Work Stages". You have the flexibility to choose which environments to associate. A screenshot of a cell phone Description automatically generated

To test this process, create a branch, make changes to a file, commit those changes, create a pull request, merge it, build and then deploy it using your release pipeline. If the work items are being linked properly, you should be able to see that information in the Details tab under the Deployment section on the Work item page, as shown in the image below:

enter image description here

Also, you can view all work items that were associated to a given release by going to the Summary page of a release run. It should look like this:

A screenshot of a cell phone Description automatically generated

For example, we need to list all work items associated to code changes that got deployed to production in the past 3 months. You will need to retrieve that data programmatically from Azure DevOps.

We have few other options as well:

  1. Queries Although you can use some work item links types as part of your query parameters, by design it is not possible to query by commits, builds or releases. The reason is those links are treated internally in the tool as a relation object instead of the conventional link objects such as Parent and Child link types.

  2. Azure DevOps Analytics Currently, the v3.0-preview of the OData Endpoint doesn’t expose all the release pipeline information we need for this report. However, it is expected that eventually this will be incorporated as part of the data model. For more information, refer the article on Extending Analytics with OData (Preview)

  3. Rest API The solution is to use the Azure DevOps REST API but there are many ways to invoke it depending on your client application type and authentication method. The link Azure DevOps Services REST API Reference has some useful information to help you decide which client technology to use.