From 7911f15d0d2ef8c0b042c4921c752fe497ba7fb3 Mon Sep 17 00:00:00 2001 From: Bryce Lampe Date: Mon, 15 Jul 2024 09:20:58 -0700 Subject: [PATCH] Pass ACTIONS environment variables --- src/Runner.Worker/Handlers/ScriptHandler.cs | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/src/Runner.Worker/Handlers/ScriptHandler.cs b/src/Runner.Worker/Handlers/ScriptHandler.cs index e6fa90a0a11..84a406ade1f 100644 --- a/src/Runner.Worker/Handlers/ScriptHandler.cs +++ b/src/Runner.Worker/Handlers/ScriptHandler.cs @@ -311,12 +311,27 @@ public async Task RunAsync(ActionRunStage stage) fileName = node; } #endif + // Add Actions Runtime server info var systemConnection = ExecutionContext.Global.Endpoints.Single(x => string.Equals(x.Name, WellKnownServiceEndpointNames.SystemVssConnection, StringComparison.OrdinalIgnoreCase)); + Environment["ACTIONS_RUNTIME_URL"] = systemConnection.Url.AbsoluteUri; + Environment["ACTIONS_RUNTIME_TOKEN"] = systemConnection.Authorization.Parameters[EndpointAuthorizationParameters.AccessToken]; + if (systemConnection.Data.TryGetValue("CacheServerUrl", out var cacheUrl) && !string.IsNullOrEmpty(cacheUrl)) + { + Environment["ACTIONS_CACHE_URL"] = cacheUrl; + } + if (systemConnection.Data.TryGetValue("PipelinesServiceUrl", out var pipelinesServiceUrl) && !string.IsNullOrEmpty(pipelinesServiceUrl)) + { + Environment["ACTIONS_RUNTIME_URL"] = pipelinesServiceUrl; + } if (systemConnection.Data.TryGetValue("GenerateIdTokenUrl", out var generateIdTokenUrl) && !string.IsNullOrEmpty(generateIdTokenUrl)) { Environment["ACTIONS_ID_TOKEN_REQUEST_URL"] = generateIdTokenUrl; Environment["ACTIONS_ID_TOKEN_REQUEST_TOKEN"] = systemConnection.Authorization.Parameters[EndpointAuthorizationParameters.AccessToken]; } + if (systemConnection.Data.TryGetValue("ResultsServiceUrl", out var resultsUrl) && !string.IsNullOrEmpty(resultsUrl)) + { + Environment["ACTIONS_RESULTS_URL"] = resultsUrl; + } ExecutionContext.Debug($"{fileName} {arguments}");