Skip to content

Commit

Permalink
Make AdoBuildRunner work on job retries
Browse files Browse the repository at this point in the history
  • Loading branch information
marcelolynch committed Jul 6, 2023
1 parent d7aeee4 commit 84d14f7
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions Public/Src/Tools/AdoBuildRunner/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,14 @@ public static async Task<int> Main(string[] args)
$"and to communicate the build information to the worker pipeline");
}

var attemptNumber = Environment.GetEnvironmentVariable(Constants.JobAttemptVariableName) ?? "1";
if (int.TryParse(attemptNumber, out var jobAttempt) && jobAttempt > 1)
{
// The job was rerun. Let's change the invocation key to reflect that
// so we don't conflict with the first run.
invocationKey += $"__jobretry_{jobAttempt}";
}

var buildContext = await api.GetBuildContextAsync(invocationKey);
var buildManager = new WorkerPipelineBuildManager(api, executor, buildContext, args, logger);
return await buildManager.BuildAsync(isOrchestrator);
Expand Down

0 comments on commit 84d14f7

Please sign in to comment.