From 84d14f7f250a618d8564384c7a226cfb5e172669 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marcelo=20Lynch=20=F0=9F=A7=89?= Date: Thu, 6 Jul 2023 09:17:02 -0700 Subject: [PATCH] Make AdoBuildRunner work on job retries --- Public/Src/Tools/AdoBuildRunner/Program.cs | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/Public/Src/Tools/AdoBuildRunner/Program.cs b/Public/Src/Tools/AdoBuildRunner/Program.cs index 238ad8e576..6a2c806eb2 100644 --- a/Public/Src/Tools/AdoBuildRunner/Program.cs +++ b/Public/Src/Tools/AdoBuildRunner/Program.cs @@ -119,6 +119,14 @@ public static async Task 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);