コード例 #1
0
        private IJobDefinition AddCorrelationPayload(IJobDefinition def, ITaskItem correlationPayload)
        {
            string path = correlationPayload.GetMetadata("FullPath");
            string uri  = correlationPayload.GetMetadata("Uri");

            if (!string.IsNullOrEmpty(uri))
            {
                Log.LogMessage(MessageImportance.Low, $"Adding Correlation Payload URI '{uri}'");
                return(def.WithCorrelationPayloadUris(new Uri(uri)));
            }

            if (Directory.Exists(path))
            {
                string includeDirectoryNameStr = correlationPayload.GetMetadata("IncludeDirectoryName");
                bool.TryParse(includeDirectoryNameStr, out bool includeDirectoryName);

                Log.LogMessage(MessageImportance.Low, $"Adding Correlation Payload Directory '{path}'");
                return(def.WithCorrelationPayloadDirectory(path, includeDirectoryName));
            }

            if (File.Exists(path))
            {
                Log.LogMessage(MessageImportance.Low, $"Adding Correlation Payload Archive '{path}'");
                return(def.WithCorrelationPayloadArchive(path));
            }

            Log.LogError($"Correlation Payload '{path}' not found.");
            return(def);
        }
コード例 #2
0
ファイル: SendHelixJob.cs プロジェクト: terrajobst/arcade
        private IJobDefinition AddCorrelationPayload(IJobDefinition def, ITaskItem correlationPayload)
        {
            string path        = correlationPayload.GetMetadata("FullPath");
            string uri         = correlationPayload.GetMetadata("Uri");
            string destination = correlationPayload.GetMetadata("Destination") ?? "";

            if (!string.IsNullOrEmpty(uri))
            {
                Log.LogMessage(MessageImportance.Low, $"Adding Correlation Payload URI '{uri}', destination '{destination}'");

                if (!string.IsNullOrEmpty(destination))
                {
                    return(def.WithCorrelationPayloadUris(new Dictionary <Uri, string>()
                    {
                        { new Uri(uri), destination }
                    }));
                }
                else
                {
                    return(def.WithCorrelationPayloadUris(new Uri(uri)));
                }
            }

            if (Directory.Exists(path))
            {
                string includeDirectoryNameStr = correlationPayload.GetMetadata("IncludeDirectoryName");
                bool.TryParse(includeDirectoryNameStr, out bool includeDirectoryName);

                Log.LogMessage(MessageImportance.Low, $"Adding Correlation Payload Directory '{path}', destination '{destination}'");
                return(def.WithCorrelationPayloadDirectory(path, includeDirectoryName, destination));
            }

            if (File.Exists(path))
            {
                Log.LogMessage(MessageImportance.Low, $"Adding Correlation Payload Archive '{path}', destination '{destination}'");
                return(def.WithCorrelationPayloadArchive(path, destination));
            }

            Log.LogError(FailureCategory.Build, $"Correlation Payload '{path}' not found.");
            return(def);
        }
コード例 #3
0
ファイル: SendHelixJob.cs プロジェクト: ViktorHofer/arcade
        private IJobDefinition AddCorrelationPayload(IJobDefinition def, ITaskItem correlationPayload)
        {
            string path        = correlationPayload.GetMetadata(MetadataNames.FullPath);
            string uri         = correlationPayload.GetMetadata(MetadataNames.Uri);
            string destination = correlationPayload.GetMetadata(MetadataNames.Destination) ?? "";

            if (!string.IsNullOrEmpty(uri))
            {
                Log.LogMessage(MessageImportance.Low, $"Adding Correlation Payload URI '{uri}', destination '{destination}'");

                if (!string.IsNullOrEmpty(destination))
                {
                    return(def.WithCorrelationPayloadUris(new Dictionary <Uri, string>()
                    {
                        { new Uri(uri), destination }
                    }));
                }
                else
                {
                    return(def.WithCorrelationPayloadUris(new Uri(uri)));
                }
            }

            if (Directory.Exists(path))
            {
                string includeDirectoryNameStr = correlationPayload.GetMetadata(MetadataNames.IncludeDirectoryName);
                if (!bool.TryParse(includeDirectoryNameStr, out bool includeDirectoryName))
                {
                    includeDirectoryName = false;
                }

                Log.LogMessage(
                    MessageImportance.Low,
                    $"Adding Correlation Payload Directory '{path}', destination '{destination}'"
                    );
                return(def.WithCorrelationPayloadDirectory(path, includeDirectoryName, destination));
            }

            if (File.Exists(path))
            {
                string asArchiveStr = correlationPayload.GetMetadata(MetadataNames.AsArchive);
                if (!bool.TryParse(asArchiveStr, out bool asArchive))
                {
                    // With no other information, default to true, since that was the previous behavior
                    // before we added the option
                    asArchive = true;
                }

                if (asArchive)
                {
                    Log.LogMessage(
                        MessageImportance.Low,
                        $"Adding Correlation Payload Archive '{path}', destination '{destination}'"
                        );
                    return(def.WithCorrelationPayloadArchive(path, destination));
                }

                Log.LogMessage(
                    MessageImportance.Low,
                    $"Adding Correlation Payload File '{path}', destination '{destination}'"
                    );
                return(def.WithCorrelationPayloadFiles(path));
            }

            Log.LogError(FailureCategory.Build, $"Correlation Payload '{path}' not found.");
            return(def);
        }