public async ValueTask GetHelixPayloads(string jobId, List <string> workItems, string downloadDir) { if (!Path.IsPathFullyQualified(downloadDir)) { downloadDir = Path.Combine(Environment.CurrentDirectory, downloadDir); } IHelixApi helixApi = _token.IsNone ? ApiFactory.GetAnonymous() : ApiFactory.GetAuthenticated(_token.Token); JobDetails jobDetails = await helixApi.Job.DetailsAsync(jobId).ConfigureAwait(false); string?jobListFile = jobDetails.JobList; if (string.IsNullOrEmpty(jobListFile)) { throw new ArgumentException($"Couldn't find job list for job {jobId}, if it is an internal job, please use a helix access token from https://helix.dot.net/Account/Tokens"); } using MemoryStream memoryStream = await _client.DownloadFileAsync(jobListFile).ConfigureAwait(false); using StreamReader reader = new StreamReader(memoryStream); string jobListJson = await reader.ReadToEndAsync().ConfigureAwait(false); WorkItemInfo[] workItemsInfo = JsonConvert.DeserializeObject <WorkItemInfo[]>(jobListJson); if (workItemsInfo.Length > 0) { Directory.CreateDirectory(downloadDir); string correlationDir = Path.Combine(downloadDir, "correlation-payload"); Directory.CreateDirectory(correlationDir); // download correlation payload JObject correlationPayload = workItemsInfo[0].CorrelationPayloadUrisWithDestinations ?? new JObject(); foreach (JProperty property in correlationPayload.Children()) { string url = property.Name; Uri uri = new Uri(url); string fileName = uri.Segments[^ 1];
public Task DownloadBuildLogAsync(string project, int buildId, int logId, Stream destinationStream) => _client.DownloadFileAsync( GetBuildLogRequestBuilder(project, buildId, logId).ToString(), destinationStream);