Exemple #1
0
        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;
        }
Exemple #3
0
        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");
            }
        }
Exemple #4
0
        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);
        }
Exemple #5
0
        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);
                }
            }
        }
Exemple #6
0
        public ActionResult TeamProject()
        {
            TeamProjectDtoCollection teamProjects = GetTfsConfigurationServer().GetAllTeamProjectsInAllTeamProjectCollections();

            return(this.View(teamProjects));
        }