Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -56,10 +56,25 @@ public async Task<Stream> DownloadPackageArtifact(string repoName, string buildI

private async Task<string> getDownloadArtifactUrl(string buildId, string artifactName, string project)
{
var pauseBetweenFailures = TimeSpan.FromSeconds(2);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is this number arbritary? or it has history to it

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

2 seconds should be ideally enough to start the delay span. So, it's just arbitrary.

var retryPolicy = Policy
.Handle<HttpRequestException>()
.WaitAndRetryAsync(5, i => pauseBetweenFailures);

var connection = await CreateVssConnection();
var buildClient = connection.GetClient<BuildHttpClient>();
var artifact = await buildClient.GetArtifactAsync(project, int.Parse(buildId), artifactName);
return artifact?.Resource?.DownloadUrl;
string url = null;
await retryPolicy.ExecuteAsync(async () =>
{
var artifact = await buildClient.GetArtifactAsync(project, int.Parse(buildId), artifactName);
url = artifact?.Resource?.DownloadUrl;
});

if (string.IsNullOrEmpty(url))
{
throw new Exception(string.Format("Failed to get download url for artifact {0} in build {1} in project {2}", artifactName, buildId, project));
}
return url;
}

private async Task<VssConnection> CreateVssConnection()
Expand Down