mohan vamsi
mohan vamsi

Reputation: 5

Is there any azure DevOps rest API that will fetch the list if releases along with their environment status by providing the build-id?

I have a problem where if I provide a build id and use 'LIST Release Azure DevOps API' it is fetching all the releases present in that build. But here the problem is that the 'LIST API' is not providing details of the environments present in the list of releases. I need to make another request with the release id to fetch the environment details for every release. Is there any option that will combine both these operations?

Upvotes: 0

Views: 605

Answers (1)

Levi Lu-MSFT
Levi Lu-MSFT

Reputation: 30373

You can provide the $expand=environments parameter in the List release API to include the details of environments in the response result. See here.

https://vsrm.dev.azure.com/{org}/{proj}/_apis/release/releases?sourceId={projectGuid}:{BuildDefinitionId}&$expand=environments&api-version=6.1-preview.8

See below example in powershell scripts:

$url = "https://vsrm.dev.azure.com/{org}/{proj}/_apis/release/releases?sourceId={projectGuid}:{BuildDefinitionId}&`$expand=environments&api-version=6.1-preview.8"

$PAT = "Personal access token"

$base64AuthInfo= [System.Convert]::ToBase64String([System.Text.Encoding]::ASCII.GetBytes(":$($PAT)"))

Invoke-RestMethod -Uri $reurl -Headers @{authorization = "Basic $base64AuthInfo"} -Method get 

Upvotes: 1

Related Questions