public void IntegrationTestUpdateRetentionPolicies() { TfsConfigurationServer tfsConfigurationServer = TfsConfigurationServerFactory.GetConfigurationServer(new Uri("myTfsUrl")); tfsConfigurationServer.Authenticate(); TeamProjectDtoCollection allTeamProjectCollections = tfsConfigurationServer.GetAllTeamProjectsInAllTeamProjectCollections(); foreach (TeamProjectDto teamProjectDto in allTeamProjectCollections) { TfsTeamProjectCollection teamProjectCollection = tfsConfigurationServer.GetTeamProjectCollection(teamProjectDto.CollectionId); IBuildServer buildServer = teamProjectCollection.GetService <IBuildServer>(); BuildServerFacade buildServerFacade = new BuildServerFacade(buildServer); buildServerFacade.UpdateRetentionPolicies(teamProjectDto.DisplayName, 1, 5, 5, 10, "All"); } }
public static BuildDefinitionDtoCollection ListTeamBuilds(Uri tfsUrl) { TfsConfigurationServer tfsConfigurationServer = TfsConfigurationServerFactory.GetConfigurationServer(tfsUrl); TeamProjectDtoCollection teamProjectCollections = tfsConfigurationServer.GetAllTeamProjectsInAllTeamProjectCollections(); BuildDefinitionDtoCollection all = new BuildDefinitionDtoCollection(); foreach (TeamProjectDto teamProjectCollection in teamProjectCollections) { BuildDefinitionDtoCollection buildDefinitionDtoCollection = tfsConfigurationServer.GetBuildDefinitions(teamProjectCollection.CollectionId, teamProjectCollection.DisplayName); foreach (BuildDefinitionDto buildDefinitionDto in buildDefinitionDtoCollection) { all.Add(buildDefinitionDto); } } return(all); }
public static void UpdateRetentionPolicies(Uri tfsUrl, string teamProjectName, int numberOfStoppedBuildsToKeep, int numberOfFailedBuildsToKeep, int numberOfPartiallySucceededBuildsToKeep, int numberOfSucceededBuildsToKeep, string deleteOptions) { TfsConfigurationServer tfsConfigurationServer = TfsConfigurationServerFactory.GetConfigurationServer(tfsUrl); tfsConfigurationServer.Authenticate(); TeamProjectDtoCollection allTeamProjectCollections = tfsConfigurationServer.GetAllTeamProjectsInAllTeamProjectCollections(); foreach (TeamProjectDto teamProjectDto in allTeamProjectCollections) { if (teamProjectDto.DisplayName == teamProjectName) { TfsTeamProjectCollection teamProjectCollection = tfsConfigurationServer.GetTeamProjectCollection(teamProjectDto.CollectionId); IBuildServer buildServer = teamProjectCollection.GetService <IBuildServer>(); BuildServerFacade buildServerFacade = new BuildServerFacade(buildServer); buildServerFacade.UpdateRetentionPolicies(teamProjectDto.DisplayName, numberOfStoppedBuildsToKeep, numberOfFailedBuildsToKeep, numberOfPartiallySucceededBuildsToKeep, numberOfSucceededBuildsToKeep, deleteOptions); } } }