mirror of
https://github.com/actions/runner.git
synced 2026-01-03 16:44:47 +08:00
Allow provide extra User-Agent for better correlation. (#2370)
This commit is contained in:
@@ -226,6 +226,20 @@ namespace GitHub.Runner.Common
|
|||||||
}
|
}
|
||||||
|
|
||||||
_userAgents.Add(new ProductInfoHeaderValue("CommitSHA", BuildConstants.Source.CommitHash));
|
_userAgents.Add(new ProductInfoHeaderValue("CommitSHA", BuildConstants.Source.CommitHash));
|
||||||
|
|
||||||
|
var extraUserAgent = Environment.GetEnvironmentVariable("GITHUB_ACTIONS_RUNNER_EXTRA_USER_AGENT");
|
||||||
|
if (!string.IsNullOrEmpty(extraUserAgent))
|
||||||
|
{
|
||||||
|
var extraUserAgentSplit = extraUserAgent.Split('/', StringSplitOptions.RemoveEmptyEntries);
|
||||||
|
if (extraUserAgentSplit.Length != 2)
|
||||||
|
{
|
||||||
|
_trace.Error($"GITHUB_ACTIONS_RUNNER_EXTRA_USER_AGENT is not in the format of 'name/version'.");
|
||||||
|
}
|
||||||
|
|
||||||
|
var extraUserAgentHeader = new ProductInfoHeaderValue(extraUserAgentSplit[0], extraUserAgentSplit[1]);
|
||||||
|
_trace.Info($"Adding extra user agent '{extraUserAgentHeader}' to all HTTP requests.");
|
||||||
|
_userAgents.Add(extraUserAgentHeader);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public string GetDirectory(WellKnownDirectory directory)
|
public string GetDirectory(WellKnownDirectory directory)
|
||||||
|
|||||||
Reference in New Issue
Block a user