Ejemplo n.º 1
0
        public static bool IsFeatureEnabled(this IVariables variables, string featureName)
        {
            var features = variables.GetStrings(KnownVariables.Package.EnabledFeatures)
                           .Where(s => !string.IsNullOrWhiteSpace(s)).ToList();

            return(features.Contains(featureName));
        }
Ejemplo n.º 2
0
        List <string> MatchingFiles(string currentDirectory, string target)
        {
            var files = fileSystem.EnumerateFilesWithGlob(currentDirectory, target).Select(Path.GetFullPath).ToList();

            foreach (var path in variables.GetStrings(ActionVariables.AdditionalPaths).Where(s => !string.IsNullOrWhiteSpace(s)))
            {
                var pathFiles = fileSystem.EnumerateFilesWithGlob(path, target).Select(Path.GetFullPath);
                files.AddRange(pathFiles);
            }

            return(files);
        }
Ejemplo n.º 3
0
        List <string> MatchingFiles(string currentDirectory, string[] sourceExtensions)
        {
            var files = fileSystem.EnumerateFilesRecursively(currentDirectory, sourceExtensions).ToList();

            foreach (var path in variables.GetStrings(ActionVariables.AdditionalPaths).Where(s => !string.IsNullOrWhiteSpace(s)))
            {
                var pathFiles = fileSystem.EnumerateFilesRecursively(path, sourceExtensions);
                files.AddRange(pathFiles);
            }

            return(files);
        }
Ejemplo n.º 4
0
        public void DoTransforms(string currentDirectory)
        {
            var appliedAsTransforms = variables.GetStrings(KnownVariables.AppliedXmlConfigTransforms, '|');

            log.Verbose("Looking for appSettings, applicationSettings, and connectionStrings in any .config files");

            if (variables.GetFlag(KnownVariables.Package.IgnoreVariableReplacementErrors))
            {
                log.Info("Variable replacement errors are suppressed because the variable Octopus.Action.Package.IgnoreVariableReplacementErrors has been set.");
            }

            foreach (var configurationFile in MatchingFiles(currentDirectory))
            {
                if (appliedAsTransforms.Contains(configurationFile))
                {
                    log.VerboseFormat("File '{0}' was interpreted as an XML configuration transform; variable substitution won't be attempted.", configurationFile);
                    continue;
                }

                replacer.ModifyConfigurationFile(configurationFile, variables);
            }
        }
Ejemplo n.º 5
0
        private static void ApplyPreservePathsDeploymentRule(DeploymentSyncOptions syncOptions,
                                                             IVariables variables)
        {
            // If PreservePaths variable set, then create SkipDelete rules for each path regex
            var preservePaths = variables.GetStrings(SpecialVariables.Action.Azure.PreservePaths, ';');

            // ReSharper disable once InvertIf
            if (preservePaths != null)
            {
                for (var i = 0; i < preservePaths.Count; i++)
                {
                    var path = preservePaths[i];
                    syncOptions.Rules.Add(new DeploymentSkipRule("SkipDeleteFiles_" + i, "Delete", "filePath", path,
                                                                 null));
                    syncOptions.Rules.Add(new DeploymentSkipRule("SkipDeleteDir_" + i, "Delete", "dirPath", path, null));
                }
            }
        }
Ejemplo n.º 6
0
        void ApplyPreservePathsDeploymentRule(DeploymentSyncOptions syncOptions,
                                              IVariables variables)
        {
            // If PreservePaths variable set, then create SkipDelete rules for each path regex
            var preservePaths = variables.GetStrings(SpecialVariables.Action.Azure.PreservePaths, ';');

            for (var i = 0; i < preservePaths.Count; i++)
            {
                var path = preservePaths[i];
                syncOptions.Rules.Add(new DeploymentSkipRule($"SkipDeleteFiles_{i}",
                                                             "Delete",
                                                             "filePath",
                                                             path,
                                                             null));
                syncOptions.Rules.Add(new DeploymentSkipRule($"SkipDeleteDir_{i}",
                                                             "Delete",
                                                             "dirPath",
                                                             path,
                                                             null));
            }
        }