-
Notifications
You must be signed in to change notification settings - Fork 1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Set runner environment in context and env #2518
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -126,6 +126,11 @@ public async Task<TaskResult> RunAsync(AgentJobRequestMessage message, Cancellat | |
_runnerSettings = HostContext.GetService<IConfigurationStore>().GetSettings(); | ||
jobContext.SetRunnerContext("name", _runnerSettings.AgentName); | ||
|
||
if (jobContext.Global.Variables.TryGetValue(WellKnownDistributedTaskVariables.RunnerEnvironment, out var runnerEnvironment)) | ||
{ | ||
jobContext.SetRunnerContext("environment", runnerEnvironment); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @TingluoHuang another q: Looking at these docs: https://docs.github.com/en/actions/learn-github-actions/variables#detecting-the-operating-system - it seems you can access the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
} | ||
|
||
string toolsDirectory = HostContext.GetDirectory(WellKnownDirectory.Tools); | ||
Directory.CreateDirectory(toolsDirectory); | ||
jobContext.SetRunnerContext("tool_cache", toolsDirectory); | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,11 @@ | ||
using System; | ||
using System; | ||
|
||
namespace GitHub.DistributedTask.WebApi | ||
{ | ||
public static class WellKnownDistributedTaskVariables | ||
{ | ||
public static readonly String JobId = "system.jobId"; | ||
public static readonly String RunnerLowDiskspaceThreshold = "system.runner.lowdiskspacethreshold"; | ||
public static readonly String RunnerEnvironment = "system.runnerEnvironment"; | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@TingluoHuang presuming this tryGetValue should make it safe to deploy this change independently of the backend change?
Also had a poke around and doesn't look like there's any allow list for what goes in the
RUNNER_{KEY}
ENV values: https://github.com/actions/runner/blob/main/src/Runner.Worker/RunnerContext.csLooks like the GitHub context does have an allow list: https://github.com/actions/runner/blob/main/src/Runner.Worker/GitHubContext.cs#L9
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We don't have an allow list before for the
RUNNER_*
since before this change allRUNNER_*
are set by the runner, while mostGITHUB_*
are coming from the service.