mirror of
https://github.com/actions/runner.git
synced 2025-12-10 12:36:23 +00:00
raise error for set-env, block set node_options. (#784)
* raise error for set-env, block set node_options. * feedback.
This commit is contained in:
committed by
TingluoHuang
parent
0d5cfff227
commit
8ba748b104
@@ -211,7 +211,7 @@ namespace GitHub.Runner.Worker
|
|||||||
// Log Telemetry and let user know they shouldn't do this
|
// Log Telemetry and let user know they shouldn't do this
|
||||||
var issue = new Issue()
|
var issue = new Issue()
|
||||||
{
|
{
|
||||||
Type = IssueType.Warning,
|
Type = IssueType.Error,
|
||||||
Message = String.Format(Constants.Runner.UnsupportedCommandMessage, this.Command)
|
Message = String.Format(Constants.Runner.UnsupportedCommandMessage, this.Command)
|
||||||
};
|
};
|
||||||
issue.Data[Constants.Runner.InternalTelemetryIssueDataKey] = Constants.Runner.UnsupportedCommand;
|
issue.Data[Constants.Runner.InternalTelemetryIssueDataKey] = Constants.Runner.UnsupportedCommand;
|
||||||
@@ -223,6 +223,24 @@ namespace GitHub.Runner.Worker
|
|||||||
throw new Exception("Required field 'name' is missing in ##[set-env] command.");
|
throw new Exception("Required field 'name' is missing in ##[set-env] command.");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
foreach (var blocked in _setEnvBlockList)
|
||||||
|
{
|
||||||
|
if (string.Equals(blocked, envName, StringComparison.OrdinalIgnoreCase))
|
||||||
|
{
|
||||||
|
// Log Telemetry and let user know they shouldn't do this
|
||||||
|
var issue = new Issue()
|
||||||
|
{
|
||||||
|
Type = IssueType.Error,
|
||||||
|
Message = $"Can't update {blocked} environment variable using ::set-env:: command."
|
||||||
|
};
|
||||||
|
issue.Data[Constants.Runner.InternalTelemetryIssueDataKey] = $"{Constants.Runner.UnsupportedCommand}_{envName}";
|
||||||
|
context.AddIssue(issue);
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
context.Global.EnvironmentVariables[envName] = command.Data;
|
context.Global.EnvironmentVariables[envName] = command.Data;
|
||||||
context.SetEnvContext(envName, command.Data);
|
context.SetEnvContext(envName, command.Data);
|
||||||
context.Debug($"{envName}='{command.Data}'");
|
context.Debug($"{envName}='{command.Data}'");
|
||||||
@@ -232,6 +250,11 @@ namespace GitHub.Runner.Worker
|
|||||||
{
|
{
|
||||||
public const String Name = "name";
|
public const String Name = "name";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private string[] _setEnvBlockList =
|
||||||
|
{
|
||||||
|
"NODE_OPTIONS"
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
public sealed class SetOutputCommandExtension : RunnerService, IActionCommandExtension
|
public sealed class SetOutputCommandExtension : RunnerService, IActionCommandExtension
|
||||||
@@ -344,7 +367,7 @@ namespace GitHub.Runner.Worker
|
|||||||
// Log Telemetry and let user know they shouldn't do this
|
// Log Telemetry and let user know they shouldn't do this
|
||||||
var issue = new Issue()
|
var issue = new Issue()
|
||||||
{
|
{
|
||||||
Type = IssueType.Warning,
|
Type = IssueType.Error,
|
||||||
Message = String.Format(Constants.Runner.UnsupportedCommandMessage, this.Command)
|
Message = String.Format(Constants.Runner.UnsupportedCommandMessage, this.Command)
|
||||||
};
|
};
|
||||||
issue.Data[Constants.Runner.InternalTelemetryIssueDataKey] = Constants.Runner.UnsupportedCommand;
|
issue.Data[Constants.Runner.InternalTelemetryIssueDataKey] = Constants.Runner.UnsupportedCommand;
|
||||||
|
|||||||
Reference in New Issue
Block a user