protected override async Task ExecuteCore(CancellationToken cancellationToken) { if (string.IsNullOrEmpty(AccessToken) && string.IsNullOrEmpty(Creator)) { Log.LogError("Creator is required when using anonymous access."); return; } if (!string.IsNullOrEmpty(AccessToken) && !string.IsNullOrEmpty(Creator)) { Log.LogError("Creator is forbidden when using authenticated access."); return; } Source = Source.ToLowerInvariant(); Type = Type.ToLowerInvariant(); Build = Build.ToLowerInvariant(); cancellationToken.ThrowIfCancellationRequested(); using (_commandPayload = new CommandPayload(this)) { var currentHelixApi = HelixApi; IJobDefinition def = currentHelixApi.Job.Define() .WithSource(Source) .WithType(Type) .WithBuild(Build) .WithTargetQueue(TargetQueue) .WithMaxRetryCount(MaxRetryCount); Log.LogMessage($"Initialized job definition with source '{Source}', type '{Type}', build number '{Build}', and target queue '{TargetQueue}'"); if (!string.IsNullOrEmpty(Creator)) { def = def.WithCreator(Creator); Log.LogMessage($"Setting creator to '{Creator}'"); } if (CorrelationPayloads != null) { foreach (ITaskItem correlationPayload in CorrelationPayloads) { def = AddCorrelationPayload(def, correlationPayload); } } if (WorkItems != null) { foreach (ITaskItem workItem in WorkItems) { def = AddWorkItem(def, workItem); } } else { Log.LogError("SendHelixJob given no WorkItems to send."); } if (_commandPayload.TryGetPayloadDirectory(out string directory)) { def = def.WithCorrelationPayloadDirectory(directory); } if (HelixProperties != null) { foreach (ITaskItem helixProperty in HelixProperties) { def = AddProperty(def, helixProperty); } } if (UsingDownloadResultsFeature) { def = def.WithDefaultResultsContainer(); } // don't send the job if we have errors if (Log.HasLoggedErrors) { return; } Log.LogMessage(MessageImportance.Normal, "Sending Job..."); cancellationToken.ThrowIfCancellationRequested(); ISentJob job = await def.SendAsync(msg => Log.LogMessage(msg)); JobCorrelationId = job.CorrelationId; ResultsContainerUri = job.ResultsContainerUri; ResultsContainerReadSAS = job.ResultsContainerReadSAS; cancellationToken.ThrowIfCancellationRequested(); } string mcUri = await GetMissionControlResultUri(); Log.LogMessage(MessageImportance.High, $"Results will be available from {mcUri}"); cancellationToken.ThrowIfCancellationRequested(); }