How to get the list of activated check-in policies for each Azure DevOps project?

To see the list of activated check-in policies for a given project, you should follow these steps in Visual Studio:

  1. Team Explorer
  2. Settings
  3. Source Control (of Team Project)
  4. Check-in Policy tab

It's OK for small number of projects. But as a QA routine, we need to make sure that we have assigned correct check-in policies for more than 500 team projects. This can not be done anymore manually. It's error-prone as our experience has shown and won't result in a consistent reliable state.

Is there another way for us to get the list of activated check-in policies on each given team project?

Upvotes: 2

Views: 180

Answers (1)

Shayki Abramczyk
Shayki Abramczyk

Reputation: 41655

You can use the old TFS (Azure DevOps on premise) API, you need this dll:

Microsoft.TeamFoundation.VersionControl.Client

The dll should exist on Microsoft.TeamFoundationServer.ExtendedClient NuGet package.

And then try this code (it works for me for TFS, maybe you need to add the authorization for Azure DevOps):

using (TfsTeamProjectCollection collection = new TfsTeamProjectCollection(new Uri("url here")))
{
    var service = collection.GetService<VersionControlServer>();
    var teamProjects = service.GetAllTeamProjects(true);
    foreach(var project in teamProjects)
    {
         var policies = project.GetCheckinPolicies();
    }
}

Upvotes: 2

Related Questions