Udostępnij za pośrednictwem


Work items between 2 releases

In Release Management UI, we show a nice list of work items that are getting deployed as part of a deployment on an environment. In this post, I will talk about how you can get the equivalent list of work items programmatically.

Let us take an example where I have a release (with name RM_M136.9 ) that I want to deploy on my environment (with name R2_WEU1). For this release, here are the work items that you see in the UI.

Before we try to find out the same list using RM APIs, let us get the releaseId for release RM_M136.9 and environmentId for environment R2_WEU1.

- To get the release id, open the release and take the releaseId from the URL https://mseng.visualstudio.com/VSOnline/\_releaseProgress?releaseId=**4630482**&\_a=release-pipeline-progress”.
- To get the environment id, open the release definition, click on the environment and take the environmentId from the URL. https://mseng.visualstudio.com/VSOnline/\_releaseDefinition?definitionId=17&\_a=definition-tasks\&environmentId=**2461**.

Now that we have both these Ids, let us use RM APIs to get the same work item list.

1. First of all, get the last deployed release on an environment. To do that, you can do that using this rest API and the response will contain the last deployed releaseId.

https://myaccountName.vsrm.visualstudio.com/myProjectName/_apis/Release/deployments?definitionId=mydefinitionId&definitionEnvironmentId=myDefinitionEnvironmentId&deploymentStatus=30&operationStatus=7960&$top=1

Example: - The response had releaseId 4580686 when following call was made.

https://mseng.vsrm.visualstudio.com/VSOnline/_apis/Release/deployments?definitionId=17&definitionEnvironmentId=532&deploymentStatus=30&operationStatus=7960&$top=1
2. Now get the work items between the release that you are about to deploy and the above found base release. To do that, use the following rest API which will return you the list of work items.
https://myaccountName.vsrm.visualstudio.com/myProjectName/_apis/Release/releases/myReleaseId/workitems?baseReleaseId=myBaseReleaseId&$top=250
Example: - The response had following workItem Ids when this call was made.

Request: https://mseng.vsrm.visualstudio.com/VSOnline/_apis/Release/releases/4630482/workitems?baseReleaseId=4580686&$top=250 Response: { "count": 47, "value": [ { "id": "1298228", "url": "https://mseng.visualstudio.com/_apis/wit/workItems/1298228" }, { "id": "1292030", "url": "https://mseng.visualstudio.com/_apis/wit/workItems/1292030" }, …. ] }
Please try this out and do let us know in case it does not work for you.

Enjoy !!