Esempio n. 1
0
        private void ProcessConfigurationStep(DeploymentStep deploymentStep)
        {
            string configuration = JsonConvert.SerializeObject(new
            {
                file    = this.variableProcessor.ProcessValue(deploymentStep.GetStringProperty("File")),
                content = this.variableProcessor.ProcessValue(deploymentStep.GetStringProperty("SetValues"))
            });

            this.deploymentClient.ProcessConfigFile(configuration);
        }
Esempio n. 2
0
        private void ProcessSQLStep(DeploymentStep deploymentStep)
        {
            string configuration = JsonConvert.SerializeObject(new
            {
                connectionString = this.variableProcessor.ProcessValue(deploymentStep.GetStringProperty("ConnectionString")),
                command          = this.variableProcessor.ProcessValue(deploymentStep.GetStringProperty("Command")),
            });

            this.deploymentClient.RunSQLScript(configuration);
        }
Esempio n. 3
0
        private void ProcessWebSiteDeploymentStep(DeploymentStep deploymentStep)
        {
            dynamic bindings = JsonConvert.DeserializeObject(this.variableProcessor.ProcessValue(deploymentStep.GetStringProperty("IIS.Bindings")));

            string configuration = JsonConvert.SerializeObject(new
            {
                destination         = this.variableProcessor.ProcessValue(deploymentStep.GetStringProperty("IIS.DestinationPath")),
                siteName            = this.variableProcessor.ProcessValue(deploymentStep.GetStringProperty("IIS.SiteName")),
                applicationPoolName = this.variableProcessor.ProcessValue(deploymentStep.GetStringProperty("IIS.SiteName")),
                projectId           = deploymentStep.GetIntProperty("ProjectId"),
                bindings            = ((IEnumerable <dynamic>)bindings)
            });

            this.deploymentClient.DeployWebSite(configuration);
        }
Esempio n. 4
0
        private void ProcessDacpacStep(DeploymentStep deploymentStep)
        {
            dynamic customConfig = JsonConvert.DeserializeObject(this.variableProcessor.ProcessValue(deploymentStep.GetStringProperty("CustomConfiguration")));

            string configuration = JsonConvert.SerializeObject(new
            {
                dacpacFileName              = "database.dacpac",
                connectionString            = this.variableProcessor.ProcessValue(deploymentStep.GetStringProperty("ConnectionString")),
                targetDatabase              = this.variableProcessor.ProcessValue(deploymentStep.GetStringProperty("TargetDatabase")),
                projectId                   = deploymentStep.GetIntProperty("ProjectId"),
                backupDatabaseBeforeChanges = (bool)customConfig.backupDatabaseBeforeChanges,
                blockOnPossibleDataLoss     = (bool)customConfig.blockOnPossibleDataLoss,
            });

            this.deploymentClient.ApplyDacpac(configuration);
        }
Esempio n. 5
0
        private void ProcessCopyFilesStep(DeploymentStep deploymentStep)
        {
            string mode = "replace";

            if (!string.IsNullOrWhiteSpace(deploymentStep.GetStringProperty("CustomConfiguration")))
            {
                dynamic customConfig = deploymentStep.GetDynamicProperty("CustomConfiguration");

                mode = customConfig.mode ?? "replace";
            }

            string configuration = JsonConvert.SerializeObject(new
            {
                destination = this.variableProcessor.ProcessValue(deploymentStep.GetStringProperty("DestinationPath")),
                projectId   = deploymentStep.GetIntProperty("ProjectId"),
                mode        = mode
            });

            this.deploymentClient.CopyFiles(configuration);
        }
Esempio n. 6
0
        public ActionResult EditStep(int id, int deploymentStepId)
        {
            this.CheckPermission(UserRoleAction.DeploymentChangeSteps);

            DeploymentStep deploymentStep = this.Entities.DeploymentStep
                                            .Include("Properties")
                                            .Include("MachineRoles")
                                            .Include("BundleVersion.Bundle")
                                            .First(ds => ds.Id == deploymentStepId && ds.BundleVersion.Id == id);

            List <MachineRole> machineRoles = this.Entities.MachineRole.ToList();

            this.ViewBag.DeploymentStep = deploymentStep;
            this.ViewBag.BundleVersion  = deploymentStep.BundleVersion;
            this.ViewBag.MachineRoles   = machineRoles;

            if (deploymentStep.Type == DeploymentStepType.DeployWebSite)
            {
                WebSiteDeploymentStepModel model = new WebSiteDeploymentStepModel
                {
                    OrderIndex       = deploymentStep.OrderIndex,
                    DeploymentStepId = deploymentStepId,
                    BundleVersionId  = deploymentStep.BundleVersionId,
                    SiteName         = deploymentStep.GetStringProperty("IIS.SiteName"),
                    ProjectId        = deploymentStep.GetIntProperty("ProjectId"),
                    Destination      = deploymentStep.GetStringProperty("IIS.DestinationPath"),
                    Roles            = string.Join(", ", deploymentStep.MachineRoles.Select(mr => mr.Name)),
                    BindingsJson     = deploymentStep.GetStringProperty("IIS.Bindings")
                };

                this.ViewBag.ProjectsSelect = this.Entities.SourceControlVersion
                                              .SelectMany(scv => scv.ProjectVersions)
                                              .Where(pv => pv.ProjectType.HasFlag(ProjectType.Web) && !pv.Project.Properties.Any(p => p.Key == "NotForDeployment" && p.Value == "true"))
                                              .Select(pv => new SelectListItem
                {
                    Text  = pv.SourceControlVersion.SourceControl.Name + " / " + pv.SourceControlVersion.Name + " / " + pv.Name,
                    Value = pv.Id.ToString()
                })
                                              .OrderBy(sli => sli.Text)
                                              .ToList();

                return(this.View("EditWebsiteStep", model));
            }
            if (deploymentStep.Type == DeploymentStepType.CopyFiles)
            {
                ZipArchiveDeploymentStepModel model = new ZipArchiveDeploymentStepModel
                {
                    OrderIndex              = deploymentStep.OrderIndex,
                    DeploymentStepId        = deploymentStepId,
                    BundleVersionId         = deploymentStep.BundleVersionId,
                    StepTitle               = deploymentStep.GetStringProperty("Step.Title"),
                    ProjectId               = deploymentStep.GetIntProperty("ProjectId"),
                    Destination             = deploymentStep.GetStringProperty("DestinationPath"),
                    Roles                   = string.Join(", ", deploymentStep.MachineRoles.Select(mr => mr.Name)),
                    CustomConfigurationJson = deploymentStep.GetStringProperty("CustomConfiguration")
                };

                this.ViewBag.ProjectsSelect = this.Entities.SourceControlVersion
                                              .SelectMany(scv => scv.ProjectVersions)
                                              .Where(pv => pv.ProjectType.HasFlag(ProjectType.ZipArchive) || pv.ProjectType.HasFlag(ProjectType.GulpFile))
                                              .Where(pv => !pv.Project.Properties.Any(p => p.Key == "NotForDeployment" && p.Value == "true"))
                                              .Select(pv => new SelectListItem
                {
                    Text  = pv.SourceControlVersion.SourceControl.Name + " / " + pv.SourceControlVersion.Name + " / " + pv.Name,
                    Value = pv.Id.ToString()
                })
                                              .OrderBy(sli => sli.Text)
                                              .ToList();

                return(this.View("EditZipArchiveStep", model));
            }

            if (deploymentStep.Type == DeploymentStepType.Configuration)
            {
                ConfigDeploymentStepModel model = new ConfigDeploymentStepModel
                {
                    OrderIndex       = deploymentStep.OrderIndex,
                    BundleVersionId  = deploymentStep.BundleVersionId,
                    DeploymentStepId = deploymentStepId,
                    ConfigJson       = deploymentStep.GetStringProperty("SetValues"),
                    StepTitle        = deploymentStep.GetStringProperty("Step.Title"),
                    File             = deploymentStep.GetStringProperty("File"),
                    Roles            = string.Join(", ", deploymentStep.MachineRoles.Select(mr => mr.Name))
                };

                return(this.View("EditConfigStep", model));
            }

            if (deploymentStep.Type == DeploymentStepType.RunSQLScript)
            {
                SqlScriptDeploymentStepModel model = new SqlScriptDeploymentStepModel
                {
                    OrderIndex       = deploymentStep.OrderIndex,
                    BundleVersionId  = deploymentStep.BundleVersionId,
                    DeploymentStepId = deploymentStepId,
                    Roles            = string.Join(", ", deploymentStep.MachineRoles.Select(mr => mr.Name)),
                    ConnectionString = deploymentStep.GetStringProperty("ConnectionString"),
                    StepTitle        = deploymentStep.GetStringProperty("Step.Title"),
                    Command          = deploymentStep.GetStringProperty("Command")
                };

                return(this.View("EditSqlScriptStep", model));
            }

            if (deploymentStep.Type == DeploymentStepType.UpdateHostsFile)
            {
                HostsDeploymentStepModel model = new HostsDeploymentStepModel
                {
                    OrderIndex       = deploymentStep.OrderIndex,
                    BundleVersionId  = deploymentStep.BundleVersionId,
                    DeploymentStepId = deploymentStepId,
                    Roles            = string.Join(", ", deploymentStep.MachineRoles.Select(mr => mr.Name)),
                    StepTitle        = deploymentStep.GetStringProperty("Step.Title"),
                    ConfigJson       = deploymentStep.GetStringProperty("ConfigurationJson")
                };

                return(this.View("EditHostsStep", model));
            }

            if (deploymentStep.Type == DeploymentStepType.DeployDacpac)
            {
                DacpacDeploymentStepModel model = new DacpacDeploymentStepModel
                {
                    OrderIndex          = deploymentStep.OrderIndex,
                    BundleVersionId     = deploymentStep.BundleVersionId,
                    DeploymentStepId    = deploymentStepId,
                    Roles               = string.Join(", ", deploymentStep.MachineRoles.Select(mr => mr.Name)),
                    StepTitle           = deploymentStep.GetStringProperty("Step.Title"),
                    ProjectId           = deploymentStep.GetIntProperty("ProjectId"),
                    ConnectionString    = deploymentStep.GetStringProperty("ConnectionString"),
                    TargetDatabase      = deploymentStep.GetStringProperty("TargetDatabase"),
                    CustomConfiguration = deploymentStep.GetStringProperty("CustomConfiguration")
                };

                this.ViewBag.ProjectsSelect = this.Entities.SourceControlVersion
                                              .SelectMany(scv => scv.ProjectVersions)
                                              .Where(pv => pv.ProjectType.HasFlag(ProjectType.Database) && !pv.Project.Properties.Any(p => p.Key == "NotForDeployment" && p.Value == "true"))
                                              .Select(pv => new SelectListItem
                {
                    Text  = pv.SourceControlVersion.SourceControl.Name + " / " + pv.SourceControlVersion.Name + " / " + pv.Name,
                    Value = pv.Id.ToString()
                })
                                              .OrderBy(sli => sli.Text)
                                              .ToList();

                return(this.View("EditDacpacStep", model));
            }

            if (deploymentStep.Type == DeploymentStepType.RunVsTests)
            {
                RunVsTestStepModel model = new RunVsTestStepModel
                {
                    OrderIndex       = deploymentStep.OrderIndex,
                    BundleVersionId  = deploymentStep.BundleVersionId,
                    DeploymentStepId = deploymentStepId,
                    Roles            = string.Join(", ", deploymentStep.MachineRoles.Select(mr => mr.Name)),
                    StepTitle        = deploymentStep.GetStringProperty("Step.Title"),
                    ProjectId        = deploymentStep.GetIntProperty("ProjectId"),
                    FiltersJson      = deploymentStep.GetStringProperty("FiltersJson"),
                    StopOnFailure    = deploymentStep.GetBoolProperty("StopOnFailure")
                };

                this.ViewBag.ProjectsSelect = this.Entities.SourceControlVersion
                                              .SelectMany(scv => scv.ProjectVersions)
                                              .Where(pv => pv.ProjectType.HasFlag(ProjectType.Test) && !pv.Project.Properties.Any(p => p.Key == "NotForDeployment" && p.Value == "true"))
                                              .Select(pv => new SelectListItem
                {
                    Text  = pv.SourceControlVersion.SourceControl.Name + " / " + pv.SourceControlVersion.Name + " / " + pv.Name,
                    Value = pv.Id.ToString()
                })
                                              .OrderBy(sli => sli.Text)
                                              .ToList();

                return(this.View("EditRunTestStep", model));
            }

            return(this.Content("Unsupported step type"));
        }
Esempio n. 7
0
 private void ProcessHostsStep(DeploymentStep deploymentStep)
 {
     this.deploymentClient.UpdateHostsFile(this.variableProcessor.ProcessValue(deploymentStep.GetStringProperty("ConfigurationJson")));
 }