private static int BranchDeployment(BranchDeploymentOptions opts) { var logMessager = new OctopusLogMessages(opts.OctopusUrl); var notifier = GetNotifier(opts.HideDeploymentProgress, opts.Teamcity, logMessager); var deploymentPlanner = new OctopusDeploymentPlanner(opts.OctopusUrl, opts.OctopusApiKey); var componentFilter = GetComponentFilter(opts.ComponentFilterPath, opts.ComponentFilter); notifier.PrintActionMessage(string.Format("Retrieve branch deployment plans for TargetEnvironment=\"{0}\" Branch=\"{1}\"", opts.TargetEnvironment, opts.Branch)); var redeployDeploymentPlans = deploymentPlanner.GetBranchDeploymentPlans(opts.TargetEnvironment, opts.Branch, opts.DoNotUseDifferentialDeployment, componentFilter); var environmentDeploymentPlan = redeployDeploymentPlans.EnvironmentDeploymentPlan; var deploymentScheduler = new DeploymentScheduler(); var componentGraph = deploymentScheduler.GetComponentDeploymentGraph(environmentDeploymentPlan); var environmentDeployment = deploymentScheduler.GetEnvironmentDeployment(componentGraph); SetUpdateVariablesOnDeploymentPlan(environmentDeployment); notifier.PrintEnvironmentDeploy(environmentDeployment); SaveEnvironmentDeploy(opts.EnvironmentDeploymentPath, environmentDeployment); var deployers = GetDeployers(opts.TargetEnvironment, opts.UpdateVariables, opts.Deploy, opts.OctopusUrl, opts.OctopusApiKey); return(Deploy(notifier, logMessager, environmentDeployment, opts.MaximumParallelDeployments, deployers)); }
public void GetDeploymentPlanForComponentDeploymentList() { var componentDependancies = GetEnvironmentDeploymentPlan(); var deploymentScheduler = new DeploymentScheduler(); var componentGraph = deploymentScheduler.GetComponentDeploymentGraph(componentDependancies); var environmentDeployment = deploymentScheduler.GetEnvironmentDeployment(componentGraph); var products0 = environmentDeployment.ProductDeployments[0]; var products1 = environmentDeployment.ProductDeployments[1]; products0.DeploymentSteps.Count().Should().Be(ExpectedNumberOfDeploymentStepsForProductDeployment0); products0.DeploymentSteps.SelectMany(productDeploymentStep => productDeploymentStep.ComponentDeployments).Count().Should().Be(ExpectedNumberOfComponentDeploymentsForProductDeployment0); products1.DeploymentSteps.Count().Should().Be(ExpectedNumberOfDeploymentStepsForProductDeployment1); products1.DeploymentSteps.SelectMany(productDeploymentStep => productDeploymentStep.ComponentDeployments).Count().Should().Be(ExpectedNumberOfComponentDeploymentsForProductDeployment1); }
public void GetEnvironmentMirrorDeploymentPlans() { var octopusUrl = ConfigurationManager.AppSettings["OctopusUrl"]; var octopusApiKey = ConfigurationManager.AppSettings["OctopusApiKey"]; var deploymentPlanner = new OctopusDeploymentPlanner(octopusUrl, octopusApiKey); var environmentFrom = ConfigurationManager.AppSettings["EnvironmentFrom"]; var environmentTo = ConfigurationManager.AppSettings["EnvironmentTo"]; var dashboard = deploymentPlanner.GetEnvironmentMirrorDeploymentPlans(environmentFrom, environmentTo, false); var deploymentScheduler = new DeploymentScheduler(); var products = deploymentScheduler.GetComponentDeploymentGraph(dashboard.EnvironmentDeploymentPlan); var difference = JsonConvert.SerializeObject(dashboard.EnvironmentDeploymentPlan.DeploymentPlans.Where(x => x.Action != PlanAction.Skip)); dashboard.EnvironmentDeploymentPlan.DeploymentPlans.Count.Should().BeGreaterThan(0); }
public void BranchDeployment() { if (!CanBranchDeployment) { return; } IsLoadingData = true; Task.Factory.StartNew(() => { try { var deploymentPlanner = new OctopusDeploymentPlanner(_octopusUrl, _octopusApiKey); var componentFilter = new ComponentFilter { Expressions = ComponentFilterExpressions.Select(x => x.Text).ToList(), Include = ComponentFilterInclude }; var branchDeploymentPlans = deploymentPlanner.GetBranchDeploymentPlans(_selectedBranchDeploymentEnvironment.Name, _selectedBranchDeploymentBranch.Name, _doNotUseDifferentialDeploymentForBranchDeployment, componentFilter); EnvironmentDeploymentPlan = branchDeploymentPlans.EnvironmentDeploymentPlan; var deploymentScheduler = new DeploymentScheduler(); var componentGraph = deploymentScheduler.GetComponentDeploymentGraph(EnvironmentDeploymentPlan); Graph = componentGraph.ToBidirectionalGraph(); EnvironmentDeployment = deploymentScheduler.GetEnvironmentDeployment(componentGraph); EnvironmentDeploymentSaveFileName = "branch " + _selectedBranchDeploymentBranch.Name + " to " + _selectedBranchDeploymentEnvironment.Name + ".json"; EnvironmentToDeployTo = _selectedBranchDeploymentEnvironment; } catch { EnvironmentDeploymentPlan = new EnvironmentDeploymentPlan(new List <ComponentDeploymentPlan>()); Graph = null; EnvironmentDeployment = new EnvironmentDeployment(new List <ProductDeployment>()); EnvironmentDeploymentSaveFileName = string.Empty; EnvironmentToDeployTo = null; } }).ContinueWith(task => { IsLoadingData = false; }); }