Пример #1
0
        // This class really needs some love.  There's a lot of behavior in here that should be pushed out into other classes that can be unit tests.
        static void Main(string[] args)
        {
            string jenkinsUrl;

            if (args.Length == 1)
                jenkinsUrl = args[0];
            else
            {
                System.Console.Write("Enter the Jenkins RSS feed url: ");
                jenkinsUrl = System.Console.ReadLine();
            }

            var feed = new JenkinsRssFeed(jenkinsUrl);
            var monitor = new BuildMonitor(feed);
            var port = GetTrafficLightPort();
            if (port == null)
                return;

            var light = new BuildLight(new TrafficLightController(port));

            light.TurnOffAllLights();

            while (true)
            {
                var currentStatus = GetCurrentStatus(monitor, feed);

                light.Update(currentStatus);

                System.Console.WriteLine("Current status: {0} {1}", currentStatus, DateTime.Now.ToShortTimeString());

                System.Threading.Thread.Sleep(10000);
            }
        }
Пример #2
0
        private static BuildStatus GetCurrentStatus(BuildMonitor monitor, JenkinsRssFeed feed)
        {
            try
            {
                return monitor.GetCurrentBuildStatus();
            }
            catch (AuthorizationFailedException)
            {
                System.Console.Write("Please enter Jenkins Username: "******"Please enter Jenkins Password: "******"Invalid Jenkins username / password combination.  Please try again.");
                    return GetCurrentStatus(monitor, feed);
                }

            }
        }