static async Task <(Build Build, HelixLogInfo?LogInfo, List <string> BadLogs)> SearchBuild( DevOpsServer server, DotNetQueryUtil queryUtil, Regex textRegex, Build build) { var badLogList = new List <string>(); try { var workItems = await queryUtil .ListHelixWorkItemsAsync(build, DotNetUtil.FailedTestOutcomes) .ConfigureAwait(false); foreach (var workItem in workItems) { var logInfo = await HelixUtil.GetHelixLogInfoAsync(server, workItem); if (logInfo.ConsoleUri is object) { var isMatch = await queryUtil.SearchFileForAnyMatchAsync( logInfo.ConsoleUri, textRegex, ex => badLogList.Add($"Unable to search helix logs {build.Id} {workItem.HelixInfo.JobId}, {logInfo.ConsoleUri}: {ex.Message}")).ConfigureAwait(false); if (isMatch) { return(build, logInfo, badLogList); } } } } catch (Exception ex) { badLogList.Add($"Unable to search helix logs for {build.Id}: {ex.Message}"); } return(build, null, badLogList); }
public async Task <List <HelixWorkItemRestInfo> > FailedWorkItems(string project, int buildNumber, [FromQuery] bool failed = false) { if (!failed) { throw new Exception("Not supported"); } var queryUtil = await QueryUtilFactory.CreateDotNetQueryUtilForUserAsync(); var build = await queryUtil.Server.GetBuildAsync(project, buildNumber); var workItems = await queryUtil.ListHelixWorkItemsAsync(build, DotNetUtil.FailedTestOutcomes); var list = new List <HelixWorkItemRestInfo>(); foreach (var workItem in workItems) { var restWorkItem = new HelixWorkItemRestInfo(); restWorkItem.Job = workItem.JobId; restWorkItem.WorkItem = workItem.WorkItemName; var logs = new List <HelixLogRestInfo>(); var logInfo = await HelixUtil.GetHelixLogInfoAsync(queryUtil.Server, workItem); foreach (var entry in logInfo.GetUris()) { logs.Add(new HelixLogRestInfo() { Name = entry.kind.ToString(), Uri = entry.Uri, }); } restWorkItem.Logs = logs.ToArray(); list.Add(restWorkItem); } return(list); }