예제 #1
0
        public async Task <List <Job> > GetJobsAsync(string pipelineName, string stageName)
        {
            try
            {
                var searchUrl = Urls.StageHistory(pipelineName, stageName);
                var uri       = new Uri(searchUrl);
                var rawData   = await Dispatch.GetRawDataAsync(uri);

                var rawStages = JsonConvert.DeserializeObject <JToken>(rawData);
                var stages    = rawStages.Value <JArray>("stages");
                var rawJobs   = stages.First().Value <JArray>("jobs");
                var jobs      = rawJobs.ToObject <List <Job> >();
                return(jobs);
            }
            catch (Exception exception)
            {
                WriteToConsoleWithColor("Broken---" + pipelineName + "---" + stageName, ConsoleColor.Red);
                WriteToConsoleWithColor(exception.Message, ConsoleColor.Red);
                return(Enumerable.Empty <Job>().ToList());
            }
        }
예제 #2
0
        public async Task <List <JobHierarchy> > GetPipelineDetailsAsync()
        {
            var searchUrl = Urls.PipelineGroups;
            var uri       = new Uri(searchUrl);
            var rawData   = await Dispatch.GetRawDataAsync(uri);

            var envs         = JsonConvert.DeserializeObject <JArray>(rawData);
            var environments = envs.ToObject <List <Environment> >();

            var jobHeirarchies = Enumerable.Empty <JobHierarchy>().ToList();

            foreach (var env in environments)
            {
                foreach (var pipeline in env.pipelines)
                {
                    foreach (var stage in pipeline.stages)
                    {
                        jobHeirarchies.Add(new JobHierarchy(env.name, pipeline.name, stage.name));
                    }
                }
            }

            return(jobHeirarchies);
        }