private JobSummary GetJobDaySummary(JobId jobId) { var client = ControllerUtil.CreateJenkinsClient(); var all = client.GetBuildInfoList(jobId).Where(x => x.State != BuildState.Running); var list = new List <JobDaySummary>(); foreach (var group in all.GroupBy(x => x.Date.Date)) { var succeeded = group.Count(x => x.State == BuildState.Succeeded); var failed = group.Count(x => x.State == BuildState.Failed); var aborted = group.Count(x => x.State == BuildState.Aborted); var averageDuration = TimeSpan.FromMilliseconds(group.Average(x => x.Duration.TotalMilliseconds)); list.Add(new JobDaySummary() { Name = jobId.Name, Date = group.Key, Succeeded = succeeded, Failed = failed, Aborted = aborted, AverageDuration = averageDuration }); } return(new JobSummary() { Name = jobId.Name, AverageDuration = TimeSpan.FromMilliseconds(all.Average(x => x.Duration.TotalMilliseconds)), JobDaySummaryList = list }); }
private List <JobQueueSummary> GetJobSummaryList(JobId jobId, int count) { var list = new List <JobQueueSummary>(); var client = ControllerUtil.CreateJenkinsClient(); foreach (var id in client.GetBuildIds(jobId).Take(count)) { var state = client.GetBuildInfo(id).State; if (state == BuildState.Running) { continue; } var time = client.GetTimeInQueue(id); if (time.HasValue) { var summary = new JobQueueSummary() { Name = jobId.Name, Id = id.Number, QueueTime = time.Value }; list.Add(summary); } } return(list.OrderBy(x => x.Id).ToList()); }
private ActionResult GetQueueJobList() { var client = ControllerUtil.CreateJenkinsClient(); var list = client.GetJobIds().Select(x => x.Name).ToList(); return(View(viewName: "QueueJobList", model: list)); }
public ActionResult Waiting() { var minimumCount = Request.GetParamInt("minimum", defaultValue: 3); var groups = ControllerUtil.CreateJenkinsClient() .GetQueuedItemInfoList() .Where(x => x.PullRequestInfo != null) .GroupBy(x => x.JobId.Name) .Where(x => x.Count() >= minimumCount); var model = new WaitingModel() { MinimumCount = minimumCount, Items = groups }; return(View(viewName: "Waiting", model: model)); }
public ActionResult Jobs(string name = null, string view = null) { var client = ControllerUtil.CreateJenkinsClient(); if (!string.IsNullOrEmpty(name)) { var jobId = JobId.ParseName(name); var jobInfo = client.GetJobInfo(jobId); if (jobInfo.JobKind == JobKind.Folder) { return(GetJobList(name, JobListContainerKind.Job, jobInfo.Jobs)); } return(GetJob(jobId)); } if (!string.IsNullOrEmpty(view)) { return(GetJobList(view, JobListContainerKind.View, client.GetJobIdsInView(view))); } return(GetJobList("Root", JobListContainerKind.Root, client.GetJobIds())); }
public ActionResult Views() { var viewList = ControllerUtil.CreateJenkinsClient().GetViews(); return(View(viewName: "ViewList", model: new ViewModel(viewList))); }