Exemplo n.º 1
0
            private static string MungeName(IActionConverterContext context, string name, string variableName)
            {
                if (string.IsNullOrEmpty(name) && string.IsNullOrEmpty(variableName))
                {
                    return(null);
                }

                if (string.IsNullOrEmpty(variableName))
                {
                    return(name);
                }

                var wrappedVariableName = "${" + variableName + "}";

                return(context.ConvertLegacyExpression(wrappedVariableName));
            }
Exemplo n.º 2
0
 public ConvertedOperation <UnzipFileOperation> ConvertActionToOperation(UnZipFileAction action, IActionConverterContext context)
 {
     return(new UnzipFileOperation
     {
         ClearTargetDirectory = string.IsNullOrEmpty(action.OverriddenTargetDirectory),
         FileName = context.ConvertLegacyExpression(PathEx.Combine(action.OverriddenSourceDirectory, action.FileName)),
         TargetDirectory = AH.NullIf(context.ConvertLegacyExpression(action.OverriddenTargetDirectory), string.Empty),
         Overwrite = true
     });
 }
Exemplo n.º 3
0
 public ConvertedOperation <CreateZipFileOperation> ConvertActionToOperation(CreateZipFileAction action, IActionConverterContext context)
 {
     return(new CreateZipFileOperation
     {
         DirectoryToZip = context.ConvertLegacyExpression(AH.NullIf(action.OverriddenSourceDirectory, string.Empty)),
         FileName = context.ConvertLegacyExpression(PathEx.Combine(action.OverriddenTargetDirectory, action.FileName)),
         Overwrite = true
     });
 }
Exemplo n.º 4
0
            public ConvertedOperation <RenameFileOperation> ConvertActionToOperation(RenameFilesAction action, IActionConverterContext context)
            {
                if (action.SourceMask.Contains("*") || action.SourceMask.Contains("?") || action.TargetMask.Contains("*") || action.TargetMask.Contains("?"))
                {
                    return(null);
                }

                return(new RenameFileOperation
                {
                    SourceFileName = context.ConvertLegacyExpression(PathEx.Combine(action.OverriddenSourceDirectory, action.SourceMask)),
                    TargetFileName = context.ConvertLegacyExpression(PathEx.Combine(action.OverriddenSourceDirectory, action.TargetMask)),
                    Overwrite = action.OverwriteExisting,
                });
            }
Exemplo n.º 5
0
            public ConvertedOperation <HttpGetOperation> ConvertActionToOperation(HttpGetAction action, IActionConverterContext context)
            {
                GetHttpMethod method;

                if (!Enum.TryParse(context.ConvertLegacyExpression(action.HttpMethod), true, out method))
                {
                    method = GetHttpMethod.GET;
                }

                return(new HttpGetOperation
                {
                    Url = context.ConvertLegacyExpression(action.Url),
                    Method = method,
                    ErrorStatusCodes = context.ConvertLegacyExpression(action.ErrorStatusCodes),
                    LogResponseBody = action.LogResponseBody,
                    ResponseBodyVariable = action.SaveResponseBodyAsVariable ? HttpActionBase.HttpResponseBodyVariableName : null
                });
            }
Exemplo n.º 6
0
 public ConvertedOperation <CreateFileOperation> ConvertActionToOperation(CreateFileAction action, IActionConverterContext context)
 {
     return(new CreateFileOperation
     {
         FileName = context.ConvertLegacyExpression(PathEx.Combine(action.OverriddenSourceDirectory, action.FileName)),
         Text = context.ConvertLegacyExpression(action.Contents),
         Overwrite = true
     });
 }
Exemplo n.º 7
0
            public ConvertedOperation <CopyFilesOperation> ConvertActionToOperation(CopyFilesAction action, IActionConverterContext context)
            {
                var masks = context.ConvertLegacyMask(action.IncludeFileMasks, action.Recursive);

                return(new CopyFilesOperation
                {
                    SourceDirectory = context.ConvertLegacyExpression(action.OverriddenSourceDirectory),
                    TargetDirectory = context.ConvertLegacyExpression(action.OverriddenTargetDirectory),
                    Includes = masks.Includes,
                    Excludes = masks.Excludes,
                    Overwrite = action.Overwrite,
                    VerboseLogging = action.VerboseLogging
                });
            }
Exemplo n.º 8
0
            public ConvertedOperation <ReplaceFileTextOperation> ConvertActionToOperation(ReplaceFileAction action, IActionConverterContext context)
            {
                var mask = context.ConvertLegacyMask(action.FileNameMasks, action.Recursive);

                return(new ReplaceFileTextOperation
                {
                    Includes = mask.Includes,
                    Excludes = mask.Excludes,
                    SearchText = context.ConvertLegacyExpression(action.SearchText),
                    ReplaceText = context.ConvertLegacyExpression(action.ReplaceText),
                    UseRegex = action.UseRegex,
                    SourceDirectory = AH.NullIf(context.ConvertLegacyExpression(action.OverriddenSourceDirectory), string.Empty)
                });
            }
Exemplo n.º 9
0
 public ConvertedOperation <SleepOperation> ConvertActionToOperation(SleepAction action, IActionConverterContext context)
 {
     return(new ConvertedOperation <SleepOperation>
     {
         [nameof(SleepOperation.Seconds)] = context.ConvertLegacyExpression(action.SecondsToSleep)
     });
 }
Exemplo n.º 10
0
 public ConvertedOperation <ExecuteProcessOperation> ConvertActionToOperation(CommandLineAction action, IActionConverterContext context)
 {
     return(new ExecuteProcessOperation
     {
         FileName = context.ConvertLegacyExpression(action.ExePath),
         Arguments = AH.NullIf(context.ConvertLegacyExpression(action.Arguments), string.Empty),
         ErrorLevel = action.DoNotFailOnStandardError ? MessageLevel.Information : MessageLevel.Error,
         WorkingDirectory = AH.NullIf(context.ConvertLegacyExpression(action.OverriddenSourceDirectory), string.Empty),
         SuccessExitCode = AH.Switch <CommandLineSuccessExitCode, string>(action.SuccessExitCode)
                           .Case(CommandLineSuccessExitCode.Zero, "0")
                           .Case(CommandLineSuccessExitCode.Negative, "<0")
                           .Case(CommandLineSuccessExitCode.Positive, ">0")
                           .Case(CommandLineSuccessExitCode.NonNegative, ">=0")
                           .Case(CommandLineSuccessExitCode.Ignore, "ignore")
                           .End()
     });
 }
Exemplo n.º 11
0
        public ConvertedOperation <QueueVsoBuildOperation> ConvertActionToOperation(QueueVsoBuildAction action, IActionConverterContext context)
        {
            var configurer = (TfsConfigurer)context.Configurer;

            return(new QueueVsoBuildOperation
            {
                BuildDefinition = action.BuildDefinition,
                UserName = configurer.UserName,
                PasswordOrToken = configurer.Password,
                Domain = configurer.Domain,
                TeamProjectCollectionUrl = configurer.BaseUrl,
                TeamProject = action.TeamProject,
                TfsBuildNumber = action.CreateBuildNumberVariable ? "$TfsBuildNumber" : null,
                ValidateBuild = action.ValidateBuild,
                WaitForCompletion = action.WaitForCompletion
            });
        }
Exemplo n.º 12
0
        public ConvertedOperation <InstallPackagesOperation> ConvertActionToOperation(InstallSolutionPackagesAction action, IActionConverterContext context)
        {
            var configurer = context.Configurer as NuGetConfigurer;

            return(new InstallPackagesOperation
            {
                SourceDirectory = context.ConvertLegacyExpression(AH.NullIf(action.OverriddenSourceDirectory, string.Empty)),
                PackageOutputDirectory = context.ConvertLegacyExpression(AH.CoalesceString(action.PackageOutputDirectory, "packages")),
                ServerUrl = AH.NullIf(configurer?.PackageSource, string.Empty)
            });
        }
Exemplo n.º 13
0
        private static string ConvertFormData(IEnumerable <KeyValuePair <string, string> > data, IActionConverterContext context)
        {
            var list = data?.ToList();

            if (list == null || list.Count == 0)
            {
                return(null);
            }

            var dictionary = new Dictionary <string, string>();

            foreach (var item in list)
            {
                dictionary[item.Key] = context.ConvertLegacyExpression(item.Value);
            }

            return(new ProcessedString(new MapTextValue(dictionary)).ToString());
        }
Exemplo n.º 14
0
            public ConvertedOperation <HttpFileUploadOperation> ConvertActionToOperation(HttpFileUploadAction action, IActionConverterContext context)
            {
                var fileName = action.FileName;

                if (!string.IsNullOrEmpty(action.OverriddenSourceDirectory))
                {
                    fileName = PathEx.Combine(action.OverriddenSourceDirectory, fileName);
                }

                return(new HttpFileUploadOperation
                {
                    Url = context.ConvertLegacyExpression(action.Url),
                    ErrorStatusCodes = context.ConvertLegacyExpression(action.ErrorStatusCodes),
                    LogResponseBody = action.LogResponseBody,
                    ResponseBodyVariable = action.SaveResponseBodyAsVariable ? HttpActionBase.HttpResponseBodyVariableName : null,
                    FileName = context.ConvertLegacyExpression(fileName)
                });
            }
Exemplo n.º 15
0
            public ConvertedOperation <HttpPostOperation> ConvertActionToOperation(HttpPostAction action, IActionConverterContext context)
            {
                PostHttpMethod method;

                if (!Enum.TryParse(context.ConvertLegacyExpression(action.HttpMethod), true, out method))
                {
                    method = PostHttpMethod.POST;
                }

                return(new ConvertedOperation <HttpPostOperation>(
                           new HttpPostOperation
                {
                    Url = context.ConvertLegacyExpression(action.Url),
                    Method = method,
                    ErrorStatusCodes = context.ConvertLegacyExpression(action.ErrorStatusCodes),
                    LogResponseBody = action.LogResponseBody,
                    ResponseBodyVariable = action.SaveResponseBodyAsVariable ? HttpActionBase.HttpResponseBodyVariableName : null,
                    ContentType = context.ConvertLegacyExpression(action.ContentType),
                    LogRequestData = action.LogRequestData,
                    PostData = AH.NullIf(context.ConvertLegacyExpression(action.PostData), string.Empty)
                }
                           )
                {
                    [nameof(HttpPostOperation.FormData)] = ConvertFormData(action.FormData, context)
                });
            }
Exemplo n.º 16
0
            public ConvertedOperation <TransferFilesOperation> ConvertActionToOperation(TransferFilesAction action, IActionConverterContext context)
            {
                var masks = context.ConvertLegacyMask(action.IncludeFileMasks, true);

                var actionConfigProp = context.GetType().GetProperty("ActionConfig", BindingFlags.NonPublic | BindingFlags.Instance);
                var actionConfig     = (Tables.ActionGroupActions_Extended)actionConfigProp.GetValue(context);

                return(new TransferFilesOperation
                {
                    SourceDirectory = context.ConvertLegacyExpression(AH.CoalesceString(action.SourceDirectory, "$WorkingDirectory")),
                    TargetDirectory = context.ConvertLegacyExpression(action.TargetDirectory),
                    DeleteTarget = action.DeleteTarget,
                    Includes = masks.Includes,
                    Excludes = masks.Excludes,
                    SourceServerName = context.ActionServerName,
                    TargetServerName = MungeName(context, actionConfig.Target_Server_Name, actionConfig.Target_Server_Variable_Name)
                });
            }
Exemplo n.º 17
0
            public ConvertedOperation <SetFileAttributesOperation> ConvertActionToOperation(SetFileAttributesAction action, IActionConverterContext context)
            {
                var mask = context.ConvertLegacyMask(action.FileMasks, action.Recursive);

                return(new SetFileAttributesOperation
                {
                    Includes = mask.Includes,
                    Excludes = mask.Excludes,
                    VerboseLogging = true,
                    SourceDirectory = AH.NullIf(context.ConvertLegacyExpression(action.OverriddenTargetDirectory), string.Empty),
                    ReadOnly = action.ReadOnly,
                    Hidden = action.Hidden,
                    System = action.System
                });
            }
Exemplo n.º 18
0
 public ConvertedOperation <SendEmailOperation> ConvertActionToOperation(SendEmailAction action, IActionConverterContext context)
 {
     return(new ConvertedOperation <SendEmailOperation>(
                new SendEmailOperation
     {
         To = from a in context.ConvertLegacyExpression(action.To)?.Split(';') ?? new string[0]
              where !string.IsNullOrWhiteSpace(a)
              select a.Trim(),
         Subject = context.ConvertLegacyExpression(action.Subject),
         BodyHtml = action.IsBodyHtml ? context.ConvertLegacyExpression(action.Message) : null,
         BodyText = !action.IsBodyHtml ? context.ConvertLegacyExpression(action.Message) : null,
         Attachments = !string.IsNullOrWhiteSpace(action.Attachment) ? new[] { context.ConvertLegacyExpression(action.Attachment) } : null
     }
                )
     {
         ServerId = action.ServerId
     });
 }
Exemplo n.º 19
0
        public ConvertedOperation <ImportVsoArtifactOperation> ConvertActionToOperation(ImportVsoArtifactAction action, IActionConverterContext context)
        {
            var configurer = (TfsConfigurer)context.Configurer;

            return(new ImportVsoArtifactOperation
            {
                ArtifactName = action.ArtifactName,
                BuildDefinition = action.BuildDefinition,
                BuildNumber = action.BuildNumber,
                UserName = configurer.UserName,
                PasswordOrToken = configurer.Password,
                Domain = configurer.Domain,
                TeamProjectCollectionUrl = configurer.BaseUrl,
                TeamProject = action.TeamProject
            });
        }
Exemplo n.º 20
0
        public ConvertedOperation <CreatePackageOperation> ConvertActionToOperation(CreatePackage action, IActionConverterContext context)
        {
            List <string> properties = null;

            if (action.Properties?.Length > 0)
            {
                properties = new List <string>(action.Properties.Length);
                foreach (var p in action.Properties)
                {
                    properties.Add(context.ConvertLegacyExpression(p));
                }
            }

            return(new CreatePackageOperation
            {
                SourceDirectory = AH.NullIf(context.ConvertLegacyExpression(action.OverriddenSourceDirectory), string.Empty),
                OutputDirectory = AH.NullIf(context.ConvertLegacyExpression(action.OverriddenTargetDirectory), string.Empty),
                Build = action.Build,
                IncludeReferencedProjects = action.IncludeReferencedProjects,
                ProjectPath = context.ConvertLegacyExpression(action.ProjectPath),
                Symbols = action.Symbols,
                Verbose = action.Verbose,
                Version = AH.NullIf(context.ConvertLegacyExpression(action.Version), string.Empty),
                Properties = properties
            });
        }
Exemplo n.º 21
0
            public ConvertedOperation <ConcatenateFilesOperation> ConvertActionToOperation(ConcatenateFilesAction action, IActionConverterContext context)
            {
                var masks     = context.ConvertLegacyMask(action.FileMasks, action.Recursive);
                var separator = AH.NullIf(context.ConvertLegacyExpression(action.ContentSeparationText), string.Empty);

                if (!string.IsNullOrEmpty(separator))
                {
                    separator = Regex.Replace(separator, @"\r?\n", action.ForceLinuxNewlines ? "${LinuxNewLine}" : "${NewLine}");
                }

                return(new ConcatenateFilesOperation
                {
                    Includes = masks.Includes,
                    Excludes = masks.Excludes,
                    ContentSeparationText = separator,
                    OutputFile = context.ConvertLegacyExpression(PathEx.Combine(action.OverriddenTargetDirectory, action.OutputFile)),
                    OutputFileEncoding = context.ConvertLegacyExpression(action.OutputFileEncoding),
                    SourceDirectory = context.ConvertLegacyExpression(AH.NullIf(action.OverriddenSourceDirectory, string.Empty))
                });
            }
Exemplo n.º 22
0
            public ConvertedOperation <DeleteFilesOperation> ConvertActionToOperation(DeleteFilesAction action, IActionConverterContext context)
            {
                var masks = context.ConvertLegacyMask(action.FileMasks, action.Recursive);

                return(new DeleteFilesOperation
                {
                    Includes = masks.Includes,
                    Excludes = masks.Excludes,
                    SourceDirectory = context.ConvertLegacyExpression(AH.NullIf(action.OverriddenSourceDirectory, string.Empty)),
                    VerboseLogging = action.LogVerbose
                });
            }
Exemplo n.º 23
0
 public ConvertedOperation <PublishPackageOperation> ConvertActionToOperation(PushPackage action, IActionConverterContext context)
 {
     return(new PublishPackageOperation
     {
         PackagePath = context.ConvertLegacyExpression(PathEx.Combine(action.OverriddenSourceDirectory, action.PackagePath)),
         ServerUrl = context.ConvertLegacyExpression(action.ServerUrl),
         ApiKey = AH.NullIf(context.ConvertLegacyExpression(action.ApiKey), string.Empty)
     });
 }
Exemplo n.º 24
0
        public ConvertedOperation <NUnitOperation> ConvertActionToOperation(NUnitAppAction action, IActionConverterContext context)
        {
            var configurerPath = (context.Configurer as NUnitConfigurer)?.NUnitConsoleExePath;

            return(new NUnitOperation
            {
                TestFile = context.ConvertLegacyExpression(PathEx.Combine(action.OverriddenSourceDirectory ?? string.Empty, action.TestFile)),
                ExePath = context.ConvertLegacyExpression(PathEx.Combine(action.OverriddenSourceDirectory ?? string.Empty, AH.CoalesceString(action.ExePath, configurerPath))),
                AdditionalArguments = AH.NullIf(context.ConvertLegacyExpression(action.AdditionalArguments), string.Empty),
                CustomXmlOutputPath = AH.NullIf(context.ConvertLegacyExpression(PathEx.Combine(action.OverriddenSourceDirectory ?? string.Empty, action.CustomXmlOutputPath)), string.Empty)
            });
        }