Exemple #1
0
        private IEnumerable <string> MakeReleasePackageRun(string action, ComponentRunContext runContext)
        {
            if (Directory.Exists(mScriptsPath))
            {
                var packageDir = runContext.Config.GetPackageDirectory(mReleaseInfo, "Scripts");
                yield return(string.Format("Scripts {0} -> {1}", mScriptsPath, packageDir));

                using (runContext.DepthScope())
                {
                    var synchronizer = new FileSynchronizer(mScriptsPath, packageDir, GetScriptsFilterByEnvironment(runContext.Environment));
                    foreach (var log in synchronizer.Run(action, runContext))
                    {
                        yield return(log);
                    }
                }

                var scriptName = mReleaseInfo.Name + @".sql";
                yield return(string.Format("Generating script {0}", scriptName));

                var sb = new StringBuilder();
                GenerateScript(runContext.Environment, sb, false, packageDir).RunToEnd();

                if (!runContext.DryRun)
                {
                    File.WriteAllText(runContext.Config.GetPackageDirectory(mReleaseInfo.Branch, scriptName), sb.ToString());
                }
            }
        }
Exemple #2
0
        private IEnumerable <string> DeployRun(string action, ComponentRunContext runContext)
        {
            if (Directory.Exists(mScriptsPath))
            {
                yield return(string.Format("Scripts: {0}", mScriptsPath));

                var sb = new StringBuilder();
                GenerateScript(runContext.Environment, sb, true, mScriptsPath).RunToEnd();

                var script = sb.ToString();
                yield return("Running script...");

                if (!runContext.DryRun)
                {
                    using (var sqlcmdResult = SqlUtils.SqlCmdExec(mDatabaseConnection, script))
                        using (runContext.DepthScope())
                        {
                            foreach (var processOutputLine in sqlcmdResult.GetOutput())
                            {
                                if (processOutputLine.OutputType == ProcessOutputLine.OutputTypeEnum.StandardError)
                                {
                                    yield return(processOutputLine.Line);
                                }
                            }

                            if (sqlcmdResult.ExitCode != 0)
                            {
                                runContext.SetError();
                            }
                        }
                }
            }
        }
Exemple #3
0
        private IEnumerable <string> GenerateScriptsRun(string action, ComponentRunContext runContext)
        {
            if (Directory.Exists(mScriptsPath))
            {
                if (!Directory.Exists(runContext.Config.ScriptsPath))
                {
                    yield return(string.Format("Creating directory {0}", runContext.Config.ScriptsPath));

                    if (!runContext.DryRun)
                    {
                        Directory.CreateDirectory(runContext.Config.ScriptsPath);
                    }
                }

                var scriptFile = Path.Combine(runContext.Config.ScriptsPath, mReleaseInfo.Branch.Name + "$" + mReleaseInfo.Name + @".sql");
                yield return(string.Format("Generating {0}", scriptFile));

                var sb = new StringBuilder();
                using (runContext.DepthScope())
                {
                    foreach (var log in GenerateScript(runContext.Environment, sb, false, mScriptsPath))
                    {
                        yield return(log);
                    }
                }

                if (!runContext.DryRun)
                {
                    File.WriteAllText(scriptFile, sb.ToString());
                }
            }
        }
        private IEnumerable<string> GenerateScriptsRun(string action, ComponentRunContext runContext)
        {
            if (Directory.Exists(mScriptsPath))
            {
                if (!Directory.Exists(runContext.Config.ScriptsPath))
                {
                    yield return string.Format("Creating directory {0}", runContext.Config.ScriptsPath);
                    if (!runContext.DryRun)
                        Directory.CreateDirectory(runContext.Config.ScriptsPath);
                }

                var scriptFile = Path.Combine(runContext.Config.ScriptsPath, mReleaseInfo.Branch.Name + "$" + mReleaseInfo.Name + @".sql");
                yield return string.Format("Generating {0}", scriptFile);

                var sb = new StringBuilder();
                using (runContext.DepthScope())
                {
                    foreach (var log in GenerateScript(runContext.Environment, sb, false, mScriptsPath))
                    {
                        yield return log;
                    }
                }

                if (!runContext.DryRun)
                {
                    File.WriteAllText(scriptFile, sb.ToString());
                }
            }
        }
        public IEnumerable <string> Run(string action, ComponentRunContext runContext)
        {
            var pre = GetPreComponent(action, runContext);

            if (pre != null)
            {
                foreach (var log in pre.Run(action, runContext))
                {
                    yield return(log);
                }
            }

            using (runContext.DepthScope())
            {
                foreach (var log in GetComponentsToRun(action, runContext).Run(action, runContext))
                {
                    yield return(log);
                }
            }

            var post = GetPostComponent(action, runContext);

            if (post != null)
            {
                foreach (var log in post.Run(action, runContext))
                {
                    yield return(log);
                }
            }
        }
        private IEnumerable<string> DeployRun(string action, ComponentRunContext runContext)
        {
            if (Directory.Exists(mScriptsPath))
            {
                yield return string.Format("Scripts: {0}", mScriptsPath);

                var sb = new StringBuilder();
                GenerateScript(runContext.Environment, sb, true, mScriptsPath).RunToEnd();

                var script = sb.ToString();
                yield return "Running script...";

                if (!runContext.DryRun)
                {
                    using (var sqlcmdResult = SqlUtils.SqlCmdExec(mDatabaseConnection, script))
                    using (runContext.DepthScope())
                    {
                        foreach (var processOutputLine in sqlcmdResult.GetOutput())
                        {
                            if (processOutputLine.OutputType == ProcessOutputLine.OutputTypeEnum.StandardError)
                                yield return processOutputLine.Line;
                        }

                        if (sqlcmdResult.ExitCode != 0)
                        {
                            runContext.SetError();
                        }
                    }
                }
            }
        }
        public IEnumerable<string> Run(string action, ComponentRunContext runContext)
        {
            var pre = GetPreComponent(action, runContext);
            if (pre != null)
            {
                foreach (var log in pre.Run(action, runContext))
                {
                    yield return log;
                }
            }

            using (runContext.DepthScope())
            {
                foreach (var log in GetComponentsToRun(action, runContext).Run(action, runContext))
                {
                    yield return log;
                }
            }

            var post = GetPostComponent(action, runContext);
            if (post != null)
            {
                foreach (var log in post.Run(action, runContext))
                {
                    yield return log;
                }
            }
        }
Exemple #8
0
        private IEnumerable <string> DeployRun(string action, ComponentRunContext runContext)
        {
            if (Directory.Exists(mReportsPath))
            {
                yield return(string.Format("Reports: {0} -> {1}", mReportsPath, mReleaseInfo.Branch.DeployPath));

                using (runContext.DepthScope())
                {
                    var synchronizer = new FileSynchronizer(mReportsPath, mReleaseInfo.Branch.DeployPath, ReportFileRegex);
                    foreach (var log in synchronizer.Run(action, runContext))
                    {
                        yield return(log);
                    }
                }
            }
        }
        private IEnumerable<string> DeployRun(string action, ComponentRunContext runContext)
        {
            if (Directory.Exists(mTemplatesPath))
            {
                yield return string.Format("Templates {0} -> {1}", mTemplatesPath, mReleaseInfo.Branch.DeployPath);

                using (runContext.DepthScope())
                {
                    var synchronizer = new FileSynchronizer(mTemplatesPath, mReleaseInfo.Branch.DeployPath, TemplateFileRegex);
                    foreach (var log in synchronizer.Run(action, runContext))
                    {
                        yield return log;
                    }
                }
            }
        }
Exemple #10
0
        private IEnumerable <string> MakeReleasePackageRun(string action, ComponentRunContext runContext)
        {
            if (Directory.Exists(mReportsPath))
            {
                var packageDir = runContext.Config.GetPackageDirectory(mReleaseInfo, "Reports+Templates");
                yield return(string.Format("Reports {0} -> {1}", mReportsPath, packageDir));

                using (runContext.DepthScope())
                {
                    var synchronizer = new FileSynchronizer(mReportsPath, packageDir, ReportFileRegex);
                    foreach (var log in synchronizer.Run(action, runContext))
                    {
                        yield return(log);
                    }
                }
            }
        }
        private IEnumerable<string> MakeReleasePackageRun(string action, ComponentRunContext runContext)
        {
            if (Directory.Exists(mTemplatesPath))
            {
                var packageDir = runContext.Config.GetPackageDirectory(mReleaseInfo, "Reports+Templates");
                yield return string.Format("Templates {0} -> {1}", mTemplatesPath, packageDir);

                using (runContext.DepthScope())
                {
                    var synchronizer = new FileSynchronizer(mTemplatesPath, packageDir, TemplateFileRegex);
                    foreach (var log in synchronizer.Run(action, runContext))
                    {
                        yield return log;
                    }
                }
            }
        }
        private IEnumerable<string> MakeReleasePackageRun(string action, ComponentRunContext runContext)
        {
            if (Directory.Exists(mScriptsPath))
            {
                var packageDir = runContext.Config.GetPackageDirectory(mReleaseInfo, "Scripts");
                yield return string.Format("Scripts {0} -> {1}", mScriptsPath, packageDir);

                using (runContext.DepthScope())
                {
                    var synchronizer = new FileSynchronizer(mScriptsPath, packageDir, GetScriptsFilterByEnvironment(runContext.Environment));
                    foreach (var log in synchronizer.Run(action, runContext))
                    {
                        yield return log;
                    }
                }

                var scriptName = mReleaseInfo.Name + @".sql";
                yield return string.Format("Generating script {0}", scriptName);

                var sb = new StringBuilder();
                GenerateScript(runContext.Environment, sb, false, packageDir).RunToEnd();

                if (!runContext.DryRun)
                {
                    File.WriteAllText(runContext.Config.GetPackageDirectory(mReleaseInfo.Branch, scriptName), sb.ToString());
                }
            }
        }