0

I can retrieve a list of releases on Azure Devops using

var releases = await releaseClient.GetReleasesAsync(project: projectName, definitionId: releaseDefinition.Id);

The releases all show the Status Active. But in the devops portal I see that some have pending tasks (Approval). How can I check that all stages ( environments ) have completed?

enter image description here

Mathias F
  • 15,906
  • 22
  • 89
  • 159

1 Answers1

2
  • How can I check that all stages have completed?

GetReleasesAsync will lists all the release status (abandoned,active,draft,undefined). If you want to check the stages status for each release. You probably need to look into the Release Environments for each specific release.

After you get all the releases by GetReleasesAsync(ProjectName, releaseDefinitionId) You can then use GetReleaseAsync(string projectName, int releaseId) to get the detailed release Environments information for the specific release by release id. If a stage is pending for approval, the status will show "inProgress"

For Below simple example.

 var releases =  releaseClient.GetReleasesAsync(Project, releaseDefinitionId).Result;

 foreach(var release in releases)
 {
     var releaseResult = releaseClient.GetReleaseAsync(Project, release.Id).Result;

     foreach (var en in releaseResult.Environments)
     {
         Console.WriteLine(en.Status);
     }
  }
Levi Lu-MSFT
  • 27,483
  • 2
  • 31
  • 43