mirror of
https://github.com/actions/runner.git
synced 2025-12-11 04:46:58 +00:00
Another runner code cleanup round (#197)
* Remove remaining non-SDK references of capabilities/demands * Remove unused Runner.Common constants * Remove more variables * Clean up RU link, and named-pipe support * Remove NotificationSocketAddress * Re-add legacy OnPremises JobDispatcher code (commented out) * More misc cleanup
This commit is contained in:
@@ -15,24 +15,12 @@ namespace GitHub.Runner.Common
|
||||
[DataContract]
|
||||
public sealed class RunnerSettings
|
||||
{
|
||||
[DataMember(EmitDefaultValue = false)]
|
||||
public bool AcceptTeeEula { get; set; }
|
||||
|
||||
[DataMember(EmitDefaultValue = false)]
|
||||
public int AgentId { get; set; }
|
||||
|
||||
[DataMember(EmitDefaultValue = false)]
|
||||
public string AgentName { get; set; }
|
||||
|
||||
[DataMember(EmitDefaultValue = false)]
|
||||
public string NotificationPipeName { get; set; }
|
||||
|
||||
[DataMember(EmitDefaultValue = false)]
|
||||
public string NotificationSocketAddress { get; set; }
|
||||
|
||||
[DataMember(EmitDefaultValue = false)]
|
||||
public bool SkipCapabilitiesScan { get; set; }
|
||||
|
||||
[DataMember(EmitDefaultValue = false)]
|
||||
public bool SkipSessionRecover { get; set; }
|
||||
|
||||
|
||||
@@ -95,35 +95,24 @@ namespace GitHub.Runner.Common
|
||||
{
|
||||
public static readonly string Agent = "agent";
|
||||
public static readonly string Auth = "auth";
|
||||
public static readonly string CollectionName = "collectionname";
|
||||
public static readonly string DeploymentGroupName = "deploymentgroupname";
|
||||
public static readonly string DeploymentPoolName = "deploymentpoolname";
|
||||
public static readonly string DeploymentGroupTags = "deploymentgrouptags";
|
||||
public static readonly string MachineGroupName = "machinegroupname";
|
||||
public static readonly string MachineGroupTags = "machinegrouptags";
|
||||
public static readonly string Matrix = "matrix";
|
||||
public static readonly string MonitorSocketAddress = "monitorsocketaddress";
|
||||
public static readonly string NotificationPipeName = "notificationpipename";
|
||||
public static readonly string NotificationSocketAddress = "notificationsocketaddress";
|
||||
public static readonly string Pool = "pool";
|
||||
public static readonly string ProjectName = "projectname";
|
||||
public static readonly string ProxyUrl = "proxyurl";
|
||||
public static readonly string ProxyUserName = "proxyusername";
|
||||
public static readonly string SslCACert = "sslcacert";
|
||||
public static readonly string SslClientCert = "sslclientcert";
|
||||
public static readonly string SslClientCertKey = "sslclientcertkey";
|
||||
public static readonly string SslClientCertArchive = "sslclientcertarchive";
|
||||
public static readonly string SslClientCertPassword = "sslclientcertpassword";
|
||||
public static readonly string StartupType = "startuptype";
|
||||
public static readonly string Url = "url";
|
||||
public static readonly string UserName = "username";
|
||||
public static readonly string WindowsLogonAccount = "windowslogonaccount";
|
||||
public static readonly string Work = "work";
|
||||
public static readonly string Yml = "yml";
|
||||
|
||||
// Secret args. Must be added to the "Secrets" getter as well.
|
||||
public static readonly string Password = "password";
|
||||
public static readonly string ProxyPassword = "proxypassword";
|
||||
public static readonly string SslClientCertPassword = "sslclientcertpassword";
|
||||
public static readonly string Token = "token";
|
||||
public static readonly string WindowsLogonPassword = "windowslogonpassword";
|
||||
public static string[] Secrets => new[]
|
||||
@@ -139,7 +128,6 @@ namespace GitHub.Runner.Common
|
||||
public static class Commands
|
||||
{
|
||||
public static readonly string Configure = "configure";
|
||||
public static readonly string LocalRun = "localRun";
|
||||
public static readonly string Remove = "remove";
|
||||
public static readonly string Run = "run";
|
||||
public static readonly string Warmup = "warmup";
|
||||
@@ -149,26 +137,16 @@ namespace GitHub.Runner.Common
|
||||
//validFlags array as well present in the CommandSettings.cs
|
||||
public static class Flags
|
||||
{
|
||||
public static readonly string AcceptTeeEula = "acceptteeeula";
|
||||
public static readonly string AddDeploymentGroupTags = "adddeploymentgrouptags";
|
||||
public static readonly string AddMachineGroupTags = "addmachinegrouptags";
|
||||
public static readonly string Commit = "commit";
|
||||
public static readonly string DeploymentGroup = "deploymentgroup";
|
||||
public static readonly string DeploymentPool = "deploymentpool";
|
||||
public static readonly string OverwriteAutoLogon = "overwriteautologon";
|
||||
public static readonly string GitUseSChannel = "gituseschannel";
|
||||
public static readonly string Help = "help";
|
||||
public static readonly string MachineGroup = "machinegroup";
|
||||
public static readonly string Replace = "replace";
|
||||
public static readonly string NoRestart = "norestart";
|
||||
public static readonly string LaunchBrowser = "launchbrowser";
|
||||
public static readonly string Once = "once";
|
||||
public static readonly string RunAsAutoLogon = "runasautologon";
|
||||
public static readonly string RunAsService = "runasservice";
|
||||
public static readonly string SslSkipCertValidation = "sslskipcertvalidation";
|
||||
public static readonly string Unattended = "unattended";
|
||||
public static readonly string Version = "version";
|
||||
public static readonly string WhatIf = "whatif";
|
||||
}
|
||||
}
|
||||
|
||||
@@ -202,14 +180,9 @@ namespace GitHub.Runner.Common
|
||||
public static class Expressions
|
||||
{
|
||||
public static readonly string Always = "always";
|
||||
public static readonly string Canceled = "canceled";
|
||||
public static readonly string Cancelled = "cancelled";
|
||||
public static readonly string Failed = "failed";
|
||||
public static readonly string Failure = "failure";
|
||||
public static readonly string Success = "success";
|
||||
public static readonly string Succeeded = "succeeded";
|
||||
public static readonly string SucceededOrFailed = "succeededOrFailed";
|
||||
public static readonly string Variables = "variables";
|
||||
}
|
||||
|
||||
public static class Path
|
||||
@@ -221,9 +194,7 @@ namespace GitHub.Runner.Common
|
||||
public static readonly string ExternalsDirectory = "externals";
|
||||
public static readonly string RunnerDiagnosticLogPrefix = "Runner_";
|
||||
public static readonly string TempDirectory = "_temp";
|
||||
public static readonly string TeeDirectory = "tee";
|
||||
public static readonly string ToolDirectory = "_tool";
|
||||
public static readonly string TaskJsonFile = "task.json";
|
||||
public static readonly string UpdateDirectory = "_update";
|
||||
public static readonly string WorkDirectory = "_work";
|
||||
public static readonly string WorkerDiagnosticLogPrefix = "Worker_";
|
||||
@@ -249,94 +220,17 @@ namespace GitHub.Runner.Common
|
||||
//
|
||||
// Keep alphabetical
|
||||
//
|
||||
public static readonly string AcceptTeeEula = "agent.acceptteeeula";
|
||||
public static readonly string AllowAllEndpoints = "agent.allowAllEndpoints"; // remove after sprint 120 or so.
|
||||
public static readonly string AllowAllSecureFiles = "agent.allowAllSecureFiles"; // remove after sprint 121 or so.
|
||||
public static readonly string BuildDirectory = "agent.builddirectory";
|
||||
public static readonly string ContainerId = "agent.containerid";
|
||||
public static readonly string ContainerNetwork = "agent.containernetwork";
|
||||
public static readonly string HomeDirectory = "agent.homedirectory";
|
||||
public static readonly string Id = "agent.id";
|
||||
public static readonly string GitUseSChannel = "agent.gituseschannel";
|
||||
public static readonly string JobName = "agent.jobname";
|
||||
public static readonly string MachineName = "agent.machinename";
|
||||
public static readonly string Name = "agent.name";
|
||||
public static readonly string OS = "agent.os";
|
||||
public static readonly string OSArchitecture = "agent.osarchitecture";
|
||||
public static readonly string OSVersion = "agent.osversion";
|
||||
public static readonly string ProxyUrl = "agent.proxyurl";
|
||||
public static readonly string ProxyUsername = "agent.proxyusername";
|
||||
public static readonly string ProxyPassword = "agent.proxypassword";
|
||||
public static readonly string ProxyBypassList = "agent.proxybypasslist";
|
||||
public static readonly string RetainDefaultEncoding = "agent.retainDefaultEncoding";
|
||||
public static readonly string RootDirectory = "agent.RootDirectory";
|
||||
public static readonly string RunMode = "agent.runmode";
|
||||
public static readonly string ServerOMDirectory = "agent.ServerOMDirectory";
|
||||
public static readonly string ServicePortPrefix = "agent.services";
|
||||
public static readonly string SslCAInfo = "agent.cainfo";
|
||||
public static readonly string SslClientCert = "agent.clientcert";
|
||||
public static readonly string SslClientCertKey = "agent.clientcertkey";
|
||||
public static readonly string SslClientCertArchive = "agent.clientcertarchive";
|
||||
public static readonly string SslClientCertPassword = "agent.clientcertpassword";
|
||||
public static readonly string SslSkipCertValidation = "agent.skipcertvalidation";
|
||||
public static readonly string TempDirectory = "agent.TempDirectory";
|
||||
public static readonly string ToolsDirectory = "agent.ToolsDirectory";
|
||||
public static readonly string Version = "agent.version";
|
||||
public static readonly string WorkFolder = "agent.workfolder";
|
||||
public static readonly string WorkingDirectory = "agent.WorkingDirectory";
|
||||
}
|
||||
|
||||
public static class Build
|
||||
{
|
||||
//
|
||||
// Keep alphabetical
|
||||
//
|
||||
public static readonly string ArtifactStagingDirectory = "build.artifactstagingdirectory";
|
||||
public static readonly string BinariesDirectory = "build.binariesdirectory";
|
||||
public static readonly string Number = "build.buildNumber";
|
||||
public static readonly string Clean = "build.clean";
|
||||
public static readonly string DefinitionName = "build.definitionname";
|
||||
public static readonly string GatedRunCI = "build.gated.runci";
|
||||
public static readonly string GatedShelvesetName = "build.gated.shelvesetname";
|
||||
public static readonly string RepoClean = "build.repository.clean";
|
||||
public static readonly string RepoGitSubmoduleCheckout = "build.repository.git.submodulecheckout";
|
||||
public static readonly string RepoId = "build.repository.id";
|
||||
public static readonly string RepoLocalPath = "build.repository.localpath";
|
||||
public static readonly string RepoName = "build.Repository.name";
|
||||
public static readonly string RepoProvider = "build.repository.provider";
|
||||
public static readonly string RepoTfvcWorkspace = "build.repository.tfvc.workspace";
|
||||
public static readonly string RepoUri = "build.repository.uri";
|
||||
public static readonly string SourceBranch = "build.sourcebranch";
|
||||
public static readonly string SourceTfvcShelveset = "build.sourcetfvcshelveset";
|
||||
public static readonly string SourceVersion = "build.sourceversion";
|
||||
public static readonly string SourcesDirectory = "build.sourcesdirectory";
|
||||
public static readonly string StagingDirectory = "build.stagingdirectory";
|
||||
public static readonly string SyncSources = "build.syncSources";
|
||||
}
|
||||
|
||||
|
||||
public static class System
|
||||
{
|
||||
//
|
||||
// Keep alphabetical
|
||||
//
|
||||
public static readonly string AccessToken = "system.accessToken";
|
||||
public static readonly string ArtifactsDirectory = "system.artifactsdirectory";
|
||||
public static readonly string CollectionId = "system.collectionid";
|
||||
public static readonly string Culture = "system.culture";
|
||||
public static readonly string DefaultWorkingDirectory = "system.defaultworkingdirectory";
|
||||
public static readonly string DefinitionId = "system.definitionid";
|
||||
public static readonly string EnableAccessToken = "system.enableAccessToken";
|
||||
public static readonly string HostType = "system.hosttype";
|
||||
public static readonly string PhaseDisplayName = "system.phaseDisplayName";
|
||||
public static readonly string PreferGitFromPath = "system.prefergitfrompath";
|
||||
public static readonly string PullRequestTargetBranchName = "system.pullrequest.targetbranch";
|
||||
public static readonly string SelfManageGitCreds = "system.selfmanagegitcreds";
|
||||
public static readonly string ServerType = "system.servertype";
|
||||
public static readonly string TFServerUrl = "system.TeamFoundationServerUri"; // back compat variable, do not document
|
||||
public static readonly string TeamProject = "system.teamproject";
|
||||
public static readonly string TeamProjectId = "system.teamProjectId";
|
||||
public static readonly string WorkFolder = "system.workfolder";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -201,8 +201,8 @@ namespace GitHub.Runner.Common
|
||||
break;
|
||||
|
||||
case WellKnownDirectory.Tools:
|
||||
// TODO: Coallesce to just check RUNNER_TOOL_CACHE when images stabilize
|
||||
path = Environment.GetEnvironmentVariable("RUNNER_TOOL_CACHE") ?? Environment.GetEnvironmentVariable("RUNNER_TOOLSDIRECTORY") ?? Environment.GetEnvironmentVariable("AGENT_TOOLSDIRECTORY") ?? Environment.GetEnvironmentVariable(Constants.Variables.Agent.ToolsDirectory);
|
||||
path = Environment.GetEnvironmentVariable("RUNNER_TOOL_CACHE");
|
||||
|
||||
if (string.IsNullOrEmpty(path))
|
||||
{
|
||||
path = Path.Combine(
|
||||
|
||||
@@ -12,53 +12,21 @@ namespace GitHub.Runner.Common
|
||||
[ServiceLocator(Default = typeof(JobNotification))]
|
||||
public interface IJobNotification : IRunnerService, IDisposable
|
||||
{
|
||||
Task JobStarted(Guid jobId, string accessToken, Uri serverUrl);
|
||||
void JobStarted(Guid jobId, string accessToken, Uri serverUrl);
|
||||
Task JobCompleted(Guid jobId);
|
||||
void StartClient(string pipeName, string monitorSocketAddress, CancellationToken cancellationToken);
|
||||
void StartClient(string socketAddress, string monitorSocketAddress);
|
||||
void StartClient(string monitorSocketAddress);
|
||||
}
|
||||
|
||||
public sealed class JobNotification : RunnerService, IJobNotification
|
||||
{
|
||||
private NamedPipeClientStream _outClient;
|
||||
private StreamWriter _writeStream;
|
||||
private Socket _socket;
|
||||
private Socket _monitorSocket;
|
||||
private bool _configured = false;
|
||||
private bool _useSockets = false;
|
||||
private bool _isMonitorConfigured = false;
|
||||
|
||||
public async Task JobStarted(Guid jobId, string accessToken, Uri serverUrl)
|
||||
public void JobStarted(Guid jobId, string accessToken, Uri serverUrl)
|
||||
{
|
||||
Trace.Info("Entering JobStarted Notification");
|
||||
|
||||
StartMonitor(jobId, accessToken, serverUrl);
|
||||
|
||||
if (_configured)
|
||||
{
|
||||
String message = $"Starting job: {jobId.ToString()}";
|
||||
if (_useSockets)
|
||||
{
|
||||
try
|
||||
{
|
||||
Trace.Info("Writing JobStarted to socket");
|
||||
_socket.Send(Encoding.UTF8.GetBytes(message));
|
||||
Trace.Info("Finished JobStarted writing to socket");
|
||||
}
|
||||
catch (SocketException e)
|
||||
{
|
||||
Trace.Error($"Failed sending message \"{message}\" on socket!");
|
||||
Trace.Error(e);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
Trace.Info("Writing JobStarted to pipe");
|
||||
await _writeStream.WriteLineAsync(message);
|
||||
await _writeStream.FlushAsync();
|
||||
Trace.Info("Finished JobStarted writing to pipe");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public async Task JobCompleted(Guid jobId)
|
||||
@@ -66,95 +34,10 @@ namespace GitHub.Runner.Common
|
||||
Trace.Info("Entering JobCompleted Notification");
|
||||
|
||||
await EndMonitor();
|
||||
|
||||
if (_configured)
|
||||
{
|
||||
String message = $"Finished job: {jobId.ToString()}";
|
||||
if (_useSockets)
|
||||
{
|
||||
try
|
||||
{
|
||||
Trace.Info("Writing JobCompleted to socket");
|
||||
_socket.Send(Encoding.UTF8.GetBytes(message));
|
||||
Trace.Info("Finished JobCompleted writing to socket");
|
||||
}
|
||||
catch (SocketException e)
|
||||
{
|
||||
Trace.Error($"Failed sending message \"{message}\" on socket!");
|
||||
Trace.Error(e);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
Trace.Info("Writing JobCompleted to pipe");
|
||||
await _writeStream.WriteLineAsync(message);
|
||||
await _writeStream.FlushAsync();
|
||||
Trace.Info("Finished JobCompleted writing to pipe");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public async void StartClient(string pipeName, string monitorSocketAddress, CancellationToken cancellationToken)
|
||||
public void StartClient(string monitorSocketAddress)
|
||||
{
|
||||
if (pipeName != null && !_configured)
|
||||
{
|
||||
Trace.Info("Connecting to named pipe {0}", pipeName);
|
||||
_outClient = new NamedPipeClientStream(".", pipeName, PipeDirection.Out, PipeOptions.Asynchronous);
|
||||
await _outClient.ConnectAsync(cancellationToken);
|
||||
_writeStream = new StreamWriter(_outClient, Encoding.UTF8);
|
||||
_configured = true;
|
||||
Trace.Info("Connection successful to named pipe {0}", pipeName);
|
||||
}
|
||||
|
||||
ConnectMonitor(monitorSocketAddress);
|
||||
}
|
||||
|
||||
public void StartClient(string socketAddress, string monitorSocketAddress)
|
||||
{
|
||||
if (!_configured)
|
||||
{
|
||||
try
|
||||
{
|
||||
string[] splitAddress = socketAddress.Split(':');
|
||||
if (splitAddress.Length != 2)
|
||||
{
|
||||
Trace.Error("Invalid socket address {0}. Job Notification will be disabled.", socketAddress);
|
||||
return;
|
||||
}
|
||||
|
||||
IPAddress address;
|
||||
try
|
||||
{
|
||||
address = IPAddress.Parse(splitAddress[0]);
|
||||
}
|
||||
catch (FormatException e)
|
||||
{
|
||||
Trace.Error("Invalid socket ip address {0}. Job Notification will be disabled",splitAddress[0]);
|
||||
Trace.Error(e);
|
||||
return;
|
||||
}
|
||||
|
||||
int port = -1;
|
||||
Int32.TryParse(splitAddress[1], out port);
|
||||
if (port < IPEndPoint.MinPort || port > IPEndPoint.MaxPort)
|
||||
{
|
||||
Trace.Error("Invalid tcp socket port {0}. Job Notification will be disabled.", splitAddress[1]);
|
||||
return;
|
||||
}
|
||||
|
||||
_socket = new Socket(SocketType.Stream, ProtocolType.Tcp);
|
||||
_socket.Connect(address, port);
|
||||
Trace.Info("Connection successful to socket {0}", socketAddress);
|
||||
_useSockets = true;
|
||||
_configured = true;
|
||||
}
|
||||
catch (SocketException e)
|
||||
{
|
||||
Trace.Error("Connection to socket {0} failed!", socketAddress);
|
||||
Trace.Error(e);
|
||||
}
|
||||
}
|
||||
|
||||
ConnectMonitor(monitorSocketAddress);
|
||||
}
|
||||
|
||||
@@ -275,15 +158,6 @@ namespace GitHub.Runner.Common
|
||||
{
|
||||
if (disposing)
|
||||
{
|
||||
_outClient?.Dispose();
|
||||
|
||||
if (_socket != null)
|
||||
{
|
||||
_socket.Send(Encoding.UTF8.GetBytes("<EOF>"));
|
||||
_socket.Shutdown(SocketShutdown.Both);
|
||||
_socket = null;
|
||||
}
|
||||
|
||||
if (_monitorSocket != null)
|
||||
{
|
||||
_monitorSocket.Send(Encoding.UTF8.GetBytes("<EOF>"));
|
||||
|
||||
@@ -293,14 +293,8 @@ namespace GitHub.Runner.Listener
|
||||
try
|
||||
{
|
||||
var notification = HostContext.GetService<IJobNotification>();
|
||||
if (!String.IsNullOrEmpty(settings.NotificationSocketAddress))
|
||||
{
|
||||
notification.StartClient(settings.NotificationSocketAddress, settings.MonitorSocketAddress);
|
||||
}
|
||||
else
|
||||
{
|
||||
notification.StartClient(settings.NotificationPipeName, settings.MonitorSocketAddress, HostContext.RunnerShutdownToken);
|
||||
}
|
||||
|
||||
notification.StartClient(settings.MonitorSocketAddress);
|
||||
|
||||
bool autoUpdateInProgress = false;
|
||||
Task<bool> selfUpdateTask = null;
|
||||
|
||||
@@ -45,7 +45,6 @@ namespace GitHub.Runner.Listener
|
||||
Constants.Runner.CommandLine.Args.Agent,
|
||||
Constants.Runner.CommandLine.Args.Auth,
|
||||
Constants.Runner.CommandLine.Args.MonitorSocketAddress,
|
||||
Constants.Runner.CommandLine.Args.NotificationPipeName,
|
||||
Constants.Runner.CommandLine.Args.Password,
|
||||
Constants.Runner.CommandLine.Args.Pool,
|
||||
Constants.Runner.CommandLine.Args.ProxyPassword,
|
||||
@@ -285,16 +284,6 @@ namespace GitHub.Runner.Listener
|
||||
return GetArg(Constants.Runner.CommandLine.Args.MonitorSocketAddress);
|
||||
}
|
||||
|
||||
public string GetNotificationPipeName()
|
||||
{
|
||||
return GetArg(Constants.Runner.CommandLine.Args.NotificationPipeName);
|
||||
}
|
||||
|
||||
public string GetNotificationSocketAddress()
|
||||
{
|
||||
return GetArg(Constants.Runner.CommandLine.Args.NotificationSocketAddress);
|
||||
}
|
||||
|
||||
// This is used to find out the source from where the Runner.Listener.exe was launched at the time of run
|
||||
public string GetStartupType()
|
||||
{
|
||||
|
||||
@@ -367,13 +367,8 @@ namespace GitHub.Runner.Listener.Configuration
|
||||
// We will Combine() what's stored with root. Defaults to string a relative path
|
||||
runnerSettings.WorkFolder = command.GetWork();
|
||||
|
||||
// notificationPipeName for Hosted agent provisioner.
|
||||
runnerSettings.NotificationPipeName = command.GetNotificationPipeName();
|
||||
|
||||
runnerSettings.MonitorSocketAddress = command.GetMonitorSocketAddress();
|
||||
|
||||
runnerSettings.NotificationSocketAddress = command.GetNotificationSocketAddress();
|
||||
|
||||
_store.SaveSettings(runnerSettings);
|
||||
|
||||
if (saveProxySetting)
|
||||
@@ -574,7 +569,7 @@ namespace GitHub.Runner.Listener.Configuration
|
||||
PublicKey = new TaskAgentPublicKey(publicKey.Exponent, publicKey.Modulus),
|
||||
};
|
||||
|
||||
// update - update instead of delete so we don't lose user capabilities etc...
|
||||
// update - update instead of delete so we don't lose labels etc...
|
||||
agent.Version = BuildConstants.RunnerPackage.Version;
|
||||
agent.OSDescription = RuntimeInformation.OSDescription;
|
||||
|
||||
|
||||
@@ -468,7 +468,7 @@ namespace GitHub.Runner.Listener
|
||||
// send notification to machine provisioner.
|
||||
var systemConnection = message.Resources.Endpoints.SingleOrDefault(x => string.Equals(x.Name, WellKnownServiceEndpointNames.SystemVssConnection, StringComparison.OrdinalIgnoreCase));
|
||||
var accessToken = systemConnection?.Authorization?.Parameters["AccessToken"];
|
||||
await notification.JobStarted(message.JobId, accessToken, systemConnection.Url);
|
||||
notification.JobStarted(message.JobId, accessToken, systemConnection.Url);
|
||||
|
||||
HostContext.WritePerfCounter($"SentJobToWorker_{requestId.ToString()}");
|
||||
|
||||
@@ -787,8 +787,10 @@ namespace GitHub.Runner.Listener
|
||||
|
||||
var jobServer = HostContext.GetService<IJobServer>();
|
||||
VssCredentials jobServerCredential = VssUtil.GetVssCredential(systemConnection);
|
||||
Uri jobServerUrl = systemConnection.Url;
|
||||
VssConnection jobConnection = VssUtil.CreateConnection(systemConnection.Url, jobServerCredential);
|
||||
|
||||
/* Below is the legacy 'OnPremises' code that is currently unused by the runner
|
||||
ToDo: re-implement code as appropriate once GHES support is added.
|
||||
// Make sure SystemConnection Url match Config Url base for OnPremises server
|
||||
if (!message.Variables.ContainsKey(Constants.Variables.System.ServerType) ||
|
||||
string.Equals(message.Variables[Constants.Variables.System.ServerType]?.Value, "OnPremises", StringComparison.OrdinalIgnoreCase))
|
||||
@@ -814,11 +816,12 @@ namespace GitHub.Runner.Listener
|
||||
//cannot parse the Uri - not a fatal error
|
||||
Trace.Error(ex);
|
||||
}
|
||||
}
|
||||
} */
|
||||
|
||||
VssConnection jobConnection = VssUtil.CreateConnection(jobServerUrl, jobServerCredential);
|
||||
await jobServer.ConnectAsync(jobConnection);
|
||||
|
||||
var timeline = await jobServer.GetTimelineAsync(message.Plan.ScopeIdentifier, message.Plan.PlanType, message.Plan.PlanId, message.Timeline.Id, CancellationToken.None);
|
||||
|
||||
ArgUtil.NotNull(timeline, nameof(timeline));
|
||||
TimelineRecord jobRecord = timeline.Records.FirstOrDefault(x => x.Id == message.JobId && x.RecordType == "Job");
|
||||
ArgUtil.NotNull(jobRecord, nameof(jobRecord));
|
||||
|
||||
@@ -874,33 +874,6 @@ namespace GitHub.Runner.Worker
|
||||
{
|
||||
this.Warning(string.Format("The job is currently being throttled by the server. You may experience delays in console line output, job status reporting, and action log uploads."));
|
||||
|
||||
if (!String.IsNullOrEmpty(this.Variables.System_TFCollectionUrl))
|
||||
{
|
||||
// Construct a URL to the resource utilization page, to aid the user debug throttling issues
|
||||
UriBuilder uriBuilder = new UriBuilder(Variables.System_TFCollectionUrl);
|
||||
NameValueCollection query = HttpUtility.ParseQueryString(uriBuilder.Query);
|
||||
DateTime endTime = DateTime.UtcNow;
|
||||
string queryDate = endTime.AddHours(-1).ToString("s") + "," + endTime.ToString("s");
|
||||
|
||||
uriBuilder.Path += (Variables.System_TFCollectionUrl.EndsWith("/") ? "" : "/") + "_usersSettings/usage";
|
||||
query["tab"] = "pipelines";
|
||||
query["queryDate"] = queryDate;
|
||||
|
||||
// Global RU link
|
||||
uriBuilder.Query = query.ToString();
|
||||
string global = $"Link to resource utilization page (global 1-hour view): {uriBuilder.ToString()}.";
|
||||
|
||||
if (!String.IsNullOrEmpty(this.Variables.Build_DefinitionName))
|
||||
{
|
||||
query["keywords"] = this.Variables.Build_Number;
|
||||
query["definition"] = this.Variables.Build_DefinitionName;
|
||||
}
|
||||
|
||||
// RU link scoped for the build/release
|
||||
uriBuilder.Query = query.ToString();
|
||||
this.Warning($"{global}\nLink to resource utilization page (1-hour view by pipeline): {uriBuilder.ToString()}.");
|
||||
}
|
||||
|
||||
_throttlingReported = true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -113,10 +113,6 @@ namespace GitHub.Runner.Worker
|
||||
Directory.CreateDirectory(toolsDirectory);
|
||||
jobContext.SetRunnerContext("tool_cache", toolsDirectory);
|
||||
|
||||
// remove variable from env
|
||||
Environment.SetEnvironmentVariable("AGENT_TOOLSDIRECTORY", null);
|
||||
Environment.SetEnvironmentVariable(Constants.Variables.Agent.ToolsDirectory, null);
|
||||
|
||||
// Setup TEMP directories
|
||||
_tempDirectoryManager = HostContext.GetService<ITempDirectoryManager>();
|
||||
_tempDirectoryManager.InitializeTempDirectory(jobContext);
|
||||
|
||||
@@ -1,12 +1,13 @@
|
||||
using GitHub.DistributedTask.WebApi;
|
||||
using GitHub.Runner.Common.Util;
|
||||
using System;
|
||||
using System;
|
||||
using System.Collections.Concurrent;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using GitHub.Build.WebApi;
|
||||
using GitHub.DistributedTask.WebApi;
|
||||
using GitHub.DistributedTask.Logging;
|
||||
using GitHub.DistributedTask.Pipelines.ContextData;
|
||||
using GitHub.Runner.Common;
|
||||
using GitHub.Runner.Common.Util;
|
||||
using GitHub.Runner.Sdk;
|
||||
|
||||
namespace GitHub.Runner.Worker
|
||||
@@ -62,10 +63,7 @@ namespace GitHub.Runner.Worker
|
||||
|
||||
// DO NOT add file path variable to here.
|
||||
// All file path variables needs to be retrive and set through ExecutionContext, so it can handle container file path translation.
|
||||
|
||||
public string Build_DefinitionName => Get(Constants.Variables.Build.DefinitionName);
|
||||
|
||||
public string Build_Number => Get(Constants.Variables.Build.Number);
|
||||
public string Build_Number => Get(BuildVariables.BuildNumber);
|
||||
|
||||
#if OS_WINDOWS
|
||||
public bool Retain_Default_Encoding => false;
|
||||
@@ -73,12 +71,8 @@ namespace GitHub.Runner.Worker
|
||||
public bool Retain_Default_Encoding => true;
|
||||
#endif
|
||||
|
||||
public string System_CollectionId => Get(Constants.Variables.System.CollectionId);
|
||||
|
||||
public bool? Step_Debug => GetBoolean(Constants.Variables.Actions.StepDebug);
|
||||
|
||||
public string System_DefinitionId => Get(Constants.Variables.System.DefinitionId);
|
||||
|
||||
public string System_PhaseDisplayName => Get(Constants.Variables.System.PhaseDisplayName);
|
||||
|
||||
public string System_TFCollectionUrl => Get(WellKnownDistributedTaskVariables.TFCollectionUrl);
|
||||
|
||||
@@ -68,13 +68,6 @@ namespace GitHub.Runner.Common.Tests
|
||||
_term.Silent = true;
|
||||
SetSingleton<ITerminal>(_term);
|
||||
EnqueueInstance<ITerminal>(_term);
|
||||
|
||||
#if !OS_WINDOWS
|
||||
string eulaFile = Path.Combine(GetDirectory(WellKnownDirectory.Externals), Constants.Path.TeeDirectory, "license.html");
|
||||
Directory.CreateDirectory(GetDirectory(WellKnownDirectory.Externals));
|
||||
Directory.CreateDirectory(Path.Combine(GetDirectory(WellKnownDirectory.Externals), Constants.Path.TeeDirectory));
|
||||
File.WriteAllText(eulaFile, "testeulafile");
|
||||
#endif
|
||||
}
|
||||
|
||||
public CultureInfo DefaultCulture { get; private set; }
|
||||
@@ -204,7 +197,8 @@ namespace GitHub.Runner.Common.Tests
|
||||
break;
|
||||
|
||||
case WellKnownDirectory.Tools:
|
||||
path = Environment.GetEnvironmentVariable("AGENT_TOOLSDIRECTORY") ?? Environment.GetEnvironmentVariable(Constants.Variables.Agent.ToolsDirectory);
|
||||
path = Environment.GetEnvironmentVariable("RUNNER_TOOL_CACHE");
|
||||
|
||||
if (string.IsNullOrEmpty(path))
|
||||
{
|
||||
path = Path.Combine(
|
||||
|
||||
Reference in New Issue
Block a user