public override void ExecuteCommand() { //HACK Must be a better way to do this?? if (string.IsNullOrEmpty(TeamCityServer)) { HelpCommand.Arguments.Add("teamcity"); HelpCommand.ExecuteCommand(); return; } var sw = new Stopwatch(); sw.Start(); Console.WriteLine("Attempting to create graph from TeamCity server: {0}", TeamCityServer); var api = new TeamCityApi(TeamCityServer); var buildConfigs = string.IsNullOrEmpty(Project) ? api.GetBuildTypes().ToList() : api.GetBuildTypes().Where(b => b.ProjectName.Equals(Project, StringComparison.InvariantCultureIgnoreCase)).ToList(); Console.WriteLine("Processing {0} build configurations...", buildConfigs.Count()); foreach (var buildConfig in buildConfigs) { var details = api.GetBuildTypeDetailsById(buildConfig.Id); AddSubscribeDataFromTriggers(buildConfig, details); if (!NoPublishStep) { AddPublishDataFromSteps(buildConfig, details); } if (!NoArtifact) { AddPublishDataFromArtifacts(buildConfig, api); } } if (NoPackageAsVertex) { BuildGraphWithPackagesAsLabels(_mappings); _simpleGraph.ToDirectedGraphML(_simpleGraph.GetVertexIdentity(), _simpleGraph.GetEdgeIdentity(), (s, n) => n.Label = s, (s, e) => e.Label = s.Tag).WriteXml(_outputFilename); } else { BuildGraphWithPackagesAsVertices(_mappings); _fancyGraph.ToDirectedGraphML(_fancyGraph.GetVertexIdentity(), _fancyGraph.GetEdgeIdentity(), GetNodeFormat(), GetEdgeFormat()).WriteXml(_outputFilename); } Console.WriteLine(); sw.Stop(); OutputElapsedTime(sw); Environment.Exit(0); }
/// <summary> /// Attempts to build a a list of PackageBuildMapping objects by interrogating a list of servers. /// </summary> /// <param name="servers">The servers to query.</param> /// <param name="useArtifactsNotPackageSteps">If set, ignore TeamCity NuGet build steps and use the existence of packages in the artifacts as proof of creation.</param> public void BuildCache(List<string> servers, bool useArtifactsNotPackageSteps = false) { foreach (var server in servers) { var apiConnection = new TeamCityApi(new CachingThreadSafeAuthenticatedRestClient(new MemoryCacheClient(), server, null), new MemoryCacheClient()); var buildConfigurations = apiConnection.GetBuildTypes(); StartedServerCheck(this, new ServerCheckEventArgs {Count = buildConfigurations.Count, Url = server}); foreach (var configuration in buildConfigurations) { StartedBuildCheck(this,new BuildMappingEventArgs(){Name = configuration.Name}); var packages = useArtifactsNotPackageSteps ? GetPackageListFromArtifacts(configuration, apiConnection).ToList() : GetPackageListFromSteps(configuration, apiConnection).ToList(); foreach (var package in packages) { PackageBuildMappings.Add(new PackageBuildMapping { BuildConfigurationId = configuration.Id, BuildConfigurationName = configuration.Name, Project = configuration.ProjectName, PackageId = package, ServerUrl = server }); } FinishedBuildCheck(this, new BuildMappingEventArgs(){Name = configuration.Name}); } FinishedServerCheck(this, new ServerCheckEventArgs(){Count = buildConfigurations.Count,Url = server}); } }
/// <summary> /// Attempts to build a a list of PackageBuildMapping objects by interrogating a list of servers. /// </summary> /// <param name="servers">The servers to query.</param> /// <param name="useArtifactsNotPackageSteps">If set, ignore TeamCity NuGet build steps and use the existence of packages in the artifacts as proof of creation.</param> public void BuildCache(List <string> servers, bool useArtifactsNotPackageSteps = false) { foreach (var server in servers) { var apiConnection = new TeamCityApi(server); var buildConfigurations = apiConnection.GetBuildTypes(); StartedServerCheck(this, new ServerCheckEventArgs() { Count = buildConfigurations.Count, Url = server }); foreach (var configuration in buildConfigurations) { StartedBuildCheck(this, new BuildMappingEventArgs() { Name = configuration.Name }); var packages = useArtifactsNotPackageSteps ? GetPackageListFromArtifacts(configuration, apiConnection).ToList() : GetPackageListFromSteps(configuration, apiConnection).ToList(); foreach (var package in packages) { PackageBuildMappings.Add(new PackageBuildMapping { BuildConfigurationId = configuration.Id, BuildConfigurationName = configuration.Name, Project = configuration.ProjectName, PackageId = package, ServerUrl = server }); } FinishedBuildCheck(this, new BuildMappingEventArgs() { Name = configuration.Name }); } FinishedServerCheck(this, new ServerCheckEventArgs() { Count = buildConfigurations.Count, Url = server }); } }