protected override async Task ProcessCommandInternalAsync( AgentTaskPluginExecutionContext context, string path, string keyStr, string salt, CancellationToken token) { TaskResult?jobStatus = null; if (context.Variables.TryGetValue("agent.jobstatus", out VariableValue jobStatusVar)) { if (Enum.TryParse <TaskResult>(jobStatusVar?.Value ?? string.Empty, true, out TaskResult result)) { jobStatus = result; } } if (!TaskResult.Succeeded.Equals(jobStatus)) { context.Warning($"Skipping because the job status was not 'Succeeded'."); return; } string[] key = keyStr.Split( new[] { '\n' }, StringSplitOptions.RemoveEmptyEntries ); PipelineCacheServer server = new PipelineCacheServer(); await server.UploadAsync( context, key, path, salt, token); }
protected override async Task ProcessCommandInternalAsync( AgentTaskPluginExecutionContext context, Fingerprint fingerprint, Func <Fingerprint[]> restoreKeysGenerator, string path, CancellationToken token) { string contentFormatValue = context.Variables.GetValueOrDefault(ContentFormatVariableName)?.Value ?? string.Empty; contentFormatValue = contentFormatValue.Trim(); ContentFormat contentFormat; if (string.IsNullOrWhiteSpace(contentFormatValue)) { contentFormat = ContentFormat.Files; } else { contentFormat = Enum.Parse <ContentFormat>(contentFormatValue, ignoreCase: true); } PipelineCacheServer server = new PipelineCacheServer(); await server.UploadAsync( context, fingerprint, path, token, contentFormat); }
protected override async Task ProcessCommandInternalAsync( AgentTaskPluginExecutionContext context, Fingerprint fingerprint, Func <Fingerprint[]> restoreKeysGenerator, string path, CancellationToken token) { bool successSoFar = false; if (context.Variables.TryGetValue("agent.jobstatus", out VariableValue jobStatusVar)) { if (Enum.TryParse <TaskResult>(jobStatusVar?.Value ?? string.Empty, true, out TaskResult jobStatus)) { if (jobStatus == TaskResult.Succeeded) { successSoFar = true; } } } if (!successSoFar) { context.Warning($"Skipping because the job status was not 'Succeeded'."); return; } bool restoreStepRan = false; if (context.TaskVariables.TryGetValue(RestoreStepRanVariableName, out VariableValue ran)) { if (ran != null && ran.Value != null && ran.Value.Equals(RestoreStepRanVariableValue, StringComparison.Ordinal)) { restoreStepRan = true; } } if (!restoreStepRan) { context.Warning($"Skipping because restore step did not run."); return; } PipelineCacheServer server = new PipelineCacheServer(); await server.UploadAsync( context, fingerprint, path, token); }
protected override async Task ProcessCommandInternalAsync( AgentTaskPluginExecutionContext context, Fingerprint fingerprint, Func <Fingerprint[]> restoreKeysGenerator, string path, CancellationToken token) { PipelineCacheServer server = new PipelineCacheServer(); await server.UploadAsync( context, fingerprint, path, token); }
protected override async Task ProcessCommandInternalAsync( AgentTaskPluginExecutionContext context, Fingerprint fingerprint, Func <Fingerprint[]> restoreKeysGenerator, string path, CancellationToken token) { context.SetTaskVariable(RestoreStepRanVariableName, RestoreStepRanVariableValue); var server = new PipelineCacheServer(); Fingerprint[] restoreFingerprints = restoreKeysGenerator(); await server.DownloadAsync( context, (new [] { fingerprint }).Concat(restoreFingerprints).ToArray(), path, context.GetInput(PipelineCacheTaskPluginConstants.CacheHitVariable, required: false), token); }
protected override async Task ProcessCommandInternalAsync( AgentTaskPluginExecutionContext context, string path, string keyStr, string salt, CancellationToken token) { string[] key = keyStr.Split( new[] { '\n' }, StringSplitOptions.RemoveEmptyEntries ); PipelineCacheServer server = new PipelineCacheServer(); await server.UploadAsync( context, key, path, salt, token); }
protected override async Task ProcessCommandInternalAsync( AgentTaskPluginExecutionContext context, Fingerprint fingerprint, Func <Fingerprint[]> restoreKeysGenerator, string path, CancellationToken token) { VariableValue packValue = context.Variables.GetValueOrDefault(PackingVariableName); string pack = packValue?.Value ?? string.Empty; string contentFomat = (!String.IsNullOrWhiteSpace(pack)) ? ContentFormatConstants.SingleTar : ContentFormatConstants.Files; PipelineCacheServer server = new PipelineCacheServer(); await server.UploadAsync( context, fingerprint, path, token, contentFomat); }
protected override async Task ProcessCommandInternalAsync( AgentTaskPluginExecutionContext context, string path, string keyStr, string salt, CancellationToken token) { string[] key = keyStr.Split( new[] { '\n' }, StringSplitOptions.RemoveEmptyEntries ); PipelineCacheServer server = new PipelineCacheServer(); await server.DownloadAsync( context, key, path, salt, context.GetInput(PipelineCacheTaskPluginConstants.CacheHitVariable, required: false), token); }
protected override async Task ProcessCommandInternalAsync( AgentTaskPluginExecutionContext context, Fingerprint keyFingerprint, Func <Fingerprint[]> restoreKeysGenerator, string[] pathSegments, string workspaceRoot, CancellationToken token) { string contentFormatValue = context.Variables.GetValueOrDefault(ContentFormatVariableName)?.Value ?? string.Empty; string calculatedFingerPrint = context.TaskVariables.GetValueOrDefault(ResolvedFingerPrintVariableName)?.Value ?? string.Empty; if (!string.IsNullOrWhiteSpace(calculatedFingerPrint) && !keyFingerprint.ToString().Equals(calculatedFingerPrint, StringComparison.Ordinal)) { context.Warning($"The given cache key has changed in it's resolved value between restore and save steps;\n" + $"original key: {calculatedFingerPrint}\n" + $"modified key: {keyFingerprint}\n"); } ContentFormat contentFormat; if (string.IsNullOrWhiteSpace(contentFormatValue)) { contentFormat = ContentFormat.SingleTar; } else { contentFormat = Enum.Parse <ContentFormat>(contentFormatValue, ignoreCase: true); } PipelineCacheServer server = new PipelineCacheServer(context); await server.UploadAsync( context, keyFingerprint, pathSegments, workspaceRoot, token, contentFormat); }