Example #1
0
        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);
        }