public static TeamProjectDtoCollection GetAllTeamProjectsInAllTeamProjectCollections(this TfsConfigurationServer tfsConfigurationServer) { if (tfsConfigurationServer == null) { throw new ArgumentNullException("tfsConfigurationServer"); } TeamProjectDtoCollection teamProjectDtoCollection = new TeamProjectDtoCollection(); ReadOnlyCollection <CatalogNode> teamProjectCollectionNodes = tfsConfigurationServer.CatalogNode.QueryChildren(new[] { CatalogResourceTypes.ProjectCollection }, false, CatalogQueryOptions.None); foreach (CatalogNode teamProjectCollectionNode in teamProjectCollectionNodes) { Guid collectionId = new Guid(teamProjectCollectionNode.Resource.Properties[TeamProjectCollectionResourcePropertyName.InstanceId]); TfsTeamProjectCollection teamProjectCollection = tfsConfigurationServer.GetTeamProjectCollection(collectionId); ReadOnlyCollection <CatalogNode> projectNodes = teamProjectCollectionNode.QueryChildren(new[] { CatalogResourceTypes.TeamProject }, false, CatalogQueryOptions.None); foreach (CatalogNode teamProjectNode in projectNodes) { TeamProjectDto teamProjectDto = new TeamProjectDto(); teamProjectDto.CollectionId = teamProjectCollection.InstanceId; teamProjectDto.CollectionName = teamProjectCollection.Name; teamProjectDto.DisplayName = teamProjectNode.Resource.DisplayName; teamProjectDto.Uri = new Uri(teamProjectNode.Resource.Properties[TeamProjectResourcePropertyName.ProjectUri]); teamProjectDto.Id = Guid.Parse(teamProjectNode.Resource.Properties[TeamProjectResourcePropertyName.ProjectId]); teamProjectDtoCollection.Add(teamProjectDto); } } return(teamProjectDtoCollection); }
public static TeamProjectDtoCollection GetAllTeamProjectsInAllTeamProjectCollections(this TfsConfigurationServer tfsConfigurationServer) { if (tfsConfigurationServer == null) { throw new ArgumentNullException("tfsConfigurationServer"); } TeamProjectDtoCollection teamProjectDtoCollection = new TeamProjectDtoCollection(); ReadOnlyCollection<CatalogNode> teamProjectCollectionNodes = tfsConfigurationServer.CatalogNode.QueryChildren(new[] { CatalogResourceTypes.ProjectCollection }, false, CatalogQueryOptions.None); foreach (CatalogNode teamProjectCollectionNode in teamProjectCollectionNodes) { Guid collectionId = new Guid(teamProjectCollectionNode.Resource.Properties[TeamProjectCollectionResourcePropertyName.InstanceId]); TfsTeamProjectCollection teamProjectCollection = tfsConfigurationServer.GetTeamProjectCollection(collectionId); ReadOnlyCollection<CatalogNode> projectNodes = teamProjectCollectionNode.QueryChildren(new[] { CatalogResourceTypes.TeamProject }, false, CatalogQueryOptions.None); foreach (CatalogNode teamProjectNode in projectNodes) { TeamProjectDto teamProjectDto = new TeamProjectDto(); teamProjectDto.CollectionId = teamProjectCollection.InstanceId; teamProjectDto.CollectionName = teamProjectCollection.Name; teamProjectDto.DisplayName = teamProjectNode.Resource.DisplayName; teamProjectDto.Uri = new Uri(teamProjectNode.Resource.Properties[TeamProjectResourcePropertyName.ProjectUri]); teamProjectDto.Id = Guid.Parse(teamProjectNode.Resource.Properties[TeamProjectResourcePropertyName.ProjectId]); teamProjectDtoCollection.Add(teamProjectDto); } } return teamProjectDtoCollection; }
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); } } }
public ActionResult TeamProject() { TeamProjectDtoCollection teamProjects = GetTfsConfigurationServer().GetAllTeamProjectsInAllTeamProjectCollections(); return(this.View(teamProjects)); }