public IExecutionContext CreateChild(Guid recordId, string displayName, string refName, Variables taskVariables = null) { Trace.Entering(); var child = new ExecutionContext(); child.Initialize(HostContext); child.Features = Features; child.Variables = Variables; child.Endpoints = Endpoints; child.SecureFiles = SecureFiles; child.TaskVariables = taskVariables; child._cancellationTokenSource = new CancellationTokenSource(); child.WriteDebug = WriteDebug; child._parentExecutionContext = this; child.PrependPath = PrependPath; child.Container = Container; child.InitializeTimelineRecord(_mainTimelineId, recordId, _record.Id, ExecutionContextType.Task, displayName, refName, ++_childTimelineRecordOrder); child._logger = HostContext.CreateService <IPagingLogger>(); child._logger.Setup(_mainTimelineId, recordId); return(child); }
public IExecutionContext CreateChild(Guid recordId, string displayName, string refName, Variables taskVariables = null, bool outputForward = false) { Trace.Entering(); var child = new ExecutionContext(); child.Initialize(HostContext); child.Features = Features; child.Variables = Variables; child.Endpoints = Endpoints; child.Repositories = Repositories; child.JobSettings = JobSettings; child.SecureFiles = SecureFiles; child.TaskVariables = taskVariables; child._cancellationTokenSource = new CancellationTokenSource(); child.WriteDebug = WriteDebug; child._parentExecutionContext = this; child.PrependPath = PrependPath; child.Containers = Containers; child.SidecarContainers = SidecarContainers; child._outputForward = outputForward; child._defaultStepTarget = _defaultStepTarget; child._currentStepTarget = _currentStepTarget; child.InitializeTimelineRecord(_mainTimelineId, recordId, _record.Id, ExecutionContextType.Task, displayName, refName, ++_childTimelineRecordOrder); child._logger = HostContext.CreateService <IPagingLogger>(); child._logger.Setup(_mainTimelineId, recordId); return(child); }
public IExecutionContext CreateChild(Guid recordId, string name, Variables taskVariables = null) { Trace.Entering(); var child = new ExecutionContext(); child.Initialize(HostContext); child.Features = Features; child.Variables = Variables; child.Endpoints = Endpoints; child.SecureFiles = SecureFiles; child.TaskVariables = taskVariables; child._cancellationTokenSource = new CancellationTokenSource(); child.WriteDebug = WriteDebug; child._parentExecutionContext = this; // the job timeline record is at order 1. child.InitializeTimelineRecord(_mainTimelineId, recordId, _record.Id, ExecutionContextType.Task, name, _childExecutionContextCount + 2); child._logger = HostContext.CreateService <IPagingLogger>(); child._logger.Setup(_mainTimelineId, recordId); _childExecutionContextCount++; return(child); }
public void InitializeJob_LogsWarningsFromVariables() { using (TestHostContext hc = new TestHostContext(this)) { // Arrange: Create a job request message. TaskOrchestrationPlanReference plan = new TaskOrchestrationPlanReference(); TimelineReference timeline = new TimelineReference(); JobEnvironment environment = new JobEnvironment(); environment.SystemConnection = new ServiceEndpoint(); environment.Variables["v1"] = "v1-$(v2)"; environment.Variables["v2"] = "v2-$(v1)"; List <TaskInstance> tasks = new List <TaskInstance>(); Guid JobId = Guid.NewGuid(); string jobName = "some job name"; var jobRequest = new AgentJobRequestMessage(plan, timeline, JobId, jobName, environment, tasks); // Arrange: Setup the configation store. var configurationStore = new Mock <IConfigurationStore>(); configurationStore.Setup(x => x.GetSettings()).Returns(new AgentSettings()); hc.SetSingleton(configurationStore.Object); // Arrange: Setup the secret masker. var secretMasker = new Mock <ISecretMasker>(); secretMasker.Setup(x => x.MaskSecrets(It.IsAny <string>())) .Returns((string x) => x); hc.SetSingleton(secretMasker.Object); // Arrange: Setup the paging logger. var pagingLogger = new Mock <IPagingLogger>(); hc.EnqueueInstance(pagingLogger.Object); // Arrange: Setup the proxy configation. var proxy = new Mock <IProxyConfiguration>(); hc.SetSingleton(proxy.Object); // Arrange: Create the execution context. hc.SetSingleton(new Mock <IJobServerQueue>().Object); var ec = new Microsoft.VisualStudio.Services.Agent.Worker.ExecutionContext(); ec.Initialize(hc); // Act. ec.InitializeJob(jobRequest, CancellationToken.None); // Assert. pagingLogger.Verify(x => x.Write(It.Is <string>(y => y.IndexOf("##[warning]") >= 0)), Times.Exactly(2)); } }
public IExecutionContext CreateChild(Guid recordId, string name) { Trace.Entering(); var child = new ExecutionContext(); child.Initialize(HostContext); child.Variables = Variables; child.Endpoints = Endpoints; child.CancellationToken = CancellationTokenSource.CreateLinkedTokenSource(CancellationToken).Token; child.WriteDebug = WriteDebug; child._parentExecutionContext = this; // the job timeline record is at order 1. child.InitializeTimelineRecord(_mainTimelineId, recordId, _record.Id, ExecutionContextType.Task, name, _childExecutionContextCount + 2); _childExecutionContextCount++; return(child); }
public IExecutionContext CreateChild(Guid recordId, string name, TimeSpan timeout) { Trace.Entering(); var child = new ExecutionContext(); child.Initialize(HostContext); child.Variables = Variables; child.Endpoints = Endpoints; child._timeoutTokenSource = new CancellationTokenSource(); child.CancellationToken = CancellationTokenSource.CreateLinkedTokenSource(CancellationToken, child._timeoutTokenSource.Token).Token; child.WriteDebug = WriteDebug; child._parentExecutionContext = this; child._timeout = timeout; // the job timeline record is at order 1. child.InitializeTimelineRecord(_mainTimelineId, recordId, _record.Id, ExecutionContextType.Task, name, _childExecutionContextCount + 2); _childExecutionContextCount++; return child; }