Ejemplo n.º 1
0
        #pragma warning restore 0649

        // Main entry point.  Simply set up a httpClient to access the CI
        // and switch on the command to invoke underlying logic.
        private static int Main(string[] args)
        {
            Config config = new Config(args);
            int    error  = 0;

            CIClient cic = new CIClient(config);

            Command currentCommand = config.DoCommand;

            switch (currentCommand)
            {
            case Command.List:
            {
                ListCommand.List(cic, config).Wait();
                break;
            }

            case Command.Copy:
            {
                CopyCommand.Copy(cic, config).Wait();
                break;
            }

            default:
            {
                Console.Error.WriteLine("super bad!  why no command!");
                error = 1;
                break;
            }
            }

            return(error);
        }
Ejemplo n.º 2
0
            // Based on the config, copy down the artifacts for the referenced job.
            // Today this is just the product bits.  This code also knows how to install
            // the bits into the asmdiff.json config file.
            public static async Task Copy(CIClient cic, Config config)
            {
                if (config.LastSuccessful)
                {
                    // Querry last successful build and extract the number.
                    var builds = cic.GetJobBuilds("dotnet_coreclr",
                                                  "master", config.JobName, true);

                    if (!builds.Result.Any())
                    {
                        Console.WriteLine("Last successful not found on server.");
                        return;
                    }

                    Build lastSuccess = builds.Result.First();
                    config.Number = lastSuccess.number;
                }

                string tag        = String.Format("{0}-{1}", config.JobName, config.Number);
                string outputPath = config.OutputPath;

                // Create directory if it doesn't exist.
                Directory.CreateDirectory(outputPath);

                // Pull down the zip file.
                DownloadZip(cic, config, outputPath).Wait();
            }
Ejemplo n.º 3
0
            // Based on the config, copy down the artifacts for the referenced job.
            // Today this is just the product bits.  This code also knows how to install
            // the bits into the asmdiff.json config file.
            public static async Task Copy(CIClient cic, Config config)
            {
                if (config.LastSuccessful)
                {
                    // Query last successful build and extract the number.
                    var builds = await cic.GetJobBuilds(config.RepoName, config.BranchName, config.JobName, true, 0, null);

                    if (!builds.Any())
                    {
                        Console.WriteLine("Last successful not found on server.");
                        return;
                    }

                    Build lastSuccess = builds.First();
                    config.Number = lastSuccess.number;
                }
                else if (config.Commit != null)
                {
                    var builds = await cic.GetJobBuilds(config.RepoName, config.BranchName, config.JobName, false, 0, config.Commit);

                    if (!builds.Any())
                    {
                        Console.WriteLine("Commit not found on server.");
                        return;
                    }

                    Build commitBuild = builds.First();
                    config.Number = commitBuild.number;
                }

                string outputPath;

                if (config.OutputRoot == null)
                {
                    outputPath = config.OutputPath;
                }
                else
                {
                    string tag = String.Format("{0}-{1}", config.JobName, config.Number);
                    outputPath = Path.Combine(config.OutputRoot, tag);
                }

                if (Directory.Exists(outputPath))
                {
                    Console.WriteLine("Warning: directory {0} already exists.", outputPath);
                }

                // Create directory if it doesn't exist.
                Directory.CreateDirectory(outputPath);

                // Pull down the zip file.
                await DownloadZip(cic, config, outputPath, config.ContentPath);
            }
Ejemplo n.º 4
0
            // Download zip file.  It's arguable that this should be in the
            private static async Task DownloadZip(CIClient cic, Config config, string outputPath)
            {
                // Copy product tools to output location.
                bool success = cic.DownloadProduct(config, outputPath).Result;

                if (config.DoUnzip)
                {
                    // unzip archive in place.
                    var zipPath = Path.Combine(outputPath, "Product.zip");
                    ZipFile.ExtractToDirectory(zipPath, outputPath);
                }
            }
Ejemplo n.º 5
0
            // Download zip file.  It's arguable that this should be in the
            private static async Task DownloadZip(CIClient cic, Config config, string outputPath, string contentPath)
            {
                // Copy product tools to output location.
                bool success = await cic.DownloadProduct(config, outputPath, contentPath);

                if (success && config.DoUnzip)
                {
                    // unzip archive in place.
                    var zipPath = Path.Combine(outputPath, Path.GetFileName(contentPath));
                    Console.WriteLine("Unzipping: {0}", zipPath);
                    ZipFile.ExtractToDirectory(zipPath, outputPath);
                }
            }
Ejemplo n.º 6
0
            // List jobs and their details from the dotnet_coreclr project on .NETCI Jenkins instance.
            // List functionality:
            //    if --job is not specified, ListOption.Jobs, list jobs under branch.
            //        (default is "master" set in Config).
            //    if --job is specified, ListOption.Builds, list job builds by id with details.
            //    if --job and --id is specified, ListOption.Number, list particular job instance,
            //        status, and artifacts.
            //
            public static async Task List(CIClient cic, Config config)
            {
                switch (config.DoListOption)
                {
                case ListOption.Jobs:
                {
                    var jobs = cic.GetProductJobs("dotnet_coreclr", "master").Result;

                    if (config.MatchPattern != null)
                    {
                        var pattern = new Regex(config.MatchPattern);
                        PrettyJobs(jobs.Where(x => pattern.IsMatch(x.name)));
                    }
                    else
                    {
                        PrettyJobs(jobs);
                    }
                }
                break;

                case ListOption.Builds:
                {
                    var builds = cic.GetJobBuilds("dotnet_coreclr",
                                                  "master", config.JobName, config.LastSuccessful);

                    if (config.LastSuccessful && builds.Result.Any())
                    {
                        Console.WriteLine("Last successful build:");
                    }

                    PrettyBuilds(builds.Result, config.Artifacts);
                }
                break;

                case ListOption.Number:
                {
                    var info = cic.GetJobBuildInfo(config.JobName, config.Number);
                    // Pretty build info
                    PrettyBuildInfo(info.Result, config.Artifacts);
                }
                break;

                default:
                {
                    Console.WriteLine("Unknown list option!");
                }
                break;
                }
            }
Ejemplo n.º 7
0
            // List jobs and their details from the given project on .NETCI Jenkins instance.
            // List functionality:
            //    if --job is not specified, ListOption.Jobs, list jobs under branch.
            //        (default is "master" set in Config).
            //    if --job is specified, ListOption.Builds, list job builds with details.
            //        --number, --last_successful, or -commit can be used to specify specific job
            //
            public static async Task List(CIClient cic, Config config)
            {
                switch (config.DoListOption)
                {
                case ListOption.Jobs:
                {
                    var jobs = await cic.GetProductJobs(config.RepoName, config.BranchName);

                    if (config.MatchPattern != null)
                    {
                        var pattern = new Regex(config.MatchPattern);
                        PrettyJobs(jobs.Where(x => pattern.IsMatch(x.name)));
                    }
                    else
                    {
                        PrettyJobs(jobs);
                    }
                }
                break;

                case ListOption.Builds:
                {
                    var builds = await cic.GetJobBuilds(config.RepoName, config.BranchName,
                                                        config.JobName, config.LastSuccessful,
                                                        config.Number, config.Commit);

                    if (config.LastSuccessful && builds.Any())
                    {
                        Console.WriteLine("Last successful build:");
                    }

                    PrettyBuilds(builds, config.Artifacts);
                }
                break;

                default:
                {
                    Console.Error.WriteLine("Unknown list option!");
                }
                break;
                }
            }
Ejemplo n.º 8
0
            // Download zip file.  It's arguable that this should be in the 
            private static async Task DownloadZip(CIClient cic, Config config, string outputPath)
            {
                // Copy product tools to output location. 
                bool success = cic.DownloadProduct(config, outputPath).Result;

                if (config.DoUnzip)
                {
                    // unzip archive in place.
                    var zipPath = Path.Combine(outputPath, "Product.zip");
                    ZipFile.ExtractToDirectory(zipPath, outputPath);
                }
            }
Ejemplo n.º 9
0
            // Based on the config, copy down the artifacts for the referenced job.
            // Today this is just the product bits.  This code also knows how to install
            // the bits into the asmdiff.json config file.
            public static async Task Copy(CIClient cic, Config config)
            {
                if (config.LastSuccessful)
                {
                    // Querry last successful build and extract the number.
                    var builds = cic.GetJobBuilds("dotnet_coreclr",
                                "master", config.JobName, true);
                    
                    if (!builds.Result.Any())
                    {
                        Console.WriteLine("Last successful not found on server.");
                        return;
                    }
                    
                    Build lastSuccess = builds.Result.First();
                    config.Number = lastSuccess.number;
                }
                
                string tag = String.Format("{0}-{1}", config.JobName, config.Number);
                string outputPath = config.OutputPath;

                // Create directory if it doesn't exist.
                Directory.CreateDirectory(outputPath);

                // Pull down the zip file.
                DownloadZip(cic, config, outputPath).Wait();
            }
Ejemplo n.º 10
0
            // List jobs and their details from the dotnet_coreclr project on .NETCI Jenkins instance.
            // List functionality:
            //    if --job is not specified, ListOption.Jobs, list jobs under branch.
            //        (default is "master" set in Config).
            //    if --job is specified, ListOption.Builds, list job builds by id with details.
            //    if --job and --id is specified, ListOption.Number, list particular job instance, 
            //        status, and artifacts.
            // 
            public static async Task List(CIClient cic, Config config)
            {
                switch (config.DoListOption)
                {
                    case ListOption.Jobs:
                        {
                            var jobs = cic.GetProductJobs("dotnet_coreclr", "master").Result;

                            if (config.MatchPattern != null)
                            {
                                var pattern = new Regex(config.MatchPattern);
                                PrettyJobs(jobs.Where(x => pattern.IsMatch(x.name)));
                            }
                            else
                            {
                                PrettyJobs(jobs);
                            }
                        }
                        break;
                    case ListOption.Builds:
                        {
                            var builds = cic.GetJobBuilds("dotnet_coreclr",
                                "master", config.JobName, config.LastSuccessful);

                            if (config.LastSuccessful && builds.Result.Any())
                            {
                                Console.WriteLine("Last successful build:");    
                            }
                            
                            PrettyBuilds(builds.Result, config.Artifacts);
                        }
                        break;
                    case ListOption.Number:
                        {
                            var info = cic.GetJobBuildInfo(config.JobName, config.Number);
                            // Pretty build info
                            PrettyBuildInfo(info.Result, config.Artifacts);
                        }
                        break;
                    default:
                        {
                            Console.WriteLine("Unknown list option!");
                        }
                        break;
                }
            }
Ejemplo n.º 11
0
        // Main entry point.  Simply set up a httpClient to access the CI
        // and switch on the command to invoke underlying logic.
        private static int Main(string[] args)
        {
            Config config = new Config(args);
            int error = 0;

            CIClient cic = new CIClient(config);

            Command currentCommand = config.DoCommand;
            switch (currentCommand)
            {
                case Command.List:
                    {
                        ListCommand.List(cic, config).Wait();
                        break;
                    }
                case Command.Copy:
                    {
                        CopyCommand.Copy(cic, config).Wait();
                        break;
                    }
                default:
                    {
                        Console.WriteLine("super bad!  why no command!");
                        error = 1;
                        break;
                    }
            }

            return error;
        }