Ejemplo n.º 1
0
        public List <FailData> GetFailedBuilds(string rootProjectIds)
        {
            var failedBuildsFromAllBranches = new List <FailData>();
            var locker = new object();

            Parallel.ForEach(rootProjectIds.Split(new[] { ';' }, StringSplitOptions.RemoveEmptyEntries), rootProjectId =>
            {
                Console.WriteLine("Retrieving failed builds for project: " + rootProjectId);
                Logger.Info("Retrieving builds for project: " + rootProjectId);
                var branchFailedBuilds = new List <FailData>();
                try
                {
                    var projects = m_TeamAdapter.GetProjects(rootProjectId, rootProjectId);
                    Logger.Info("Found {0} projects under project {1}", projects.Length, rootProjectId);
                    foreach (var project in projects)
                    {
                        var answer = GetFailedBuildsWithResponsiblesEmails(project);
                        branchFailedBuilds.AddRange(answer);
                    }
                    Logger.Info("Found {0} failed builds under project {1} with no investigator", branchFailedBuilds.Count, rootProjectId);
                    Console.WriteLine("Finished retrieving failed builds for project: " + rootProjectId);
                }
                catch (Exception ex)
                {
                    Logger.Error("Error retrieving failed builds for project {0}: {1}", rootProjectId, ex.ToString());
                    Console.WriteLine("Error retrieving failed builds for project {0}", rootProjectId);
                }

                lock (locker)
                {
                    failedBuildsFromAllBranches.AddRange(branchFailedBuilds);
                }
            });

            return(failedBuildsFromAllBranches);
        }