Exemple #1
0
        public void DeployOctopusRelease(string projectName, VersionResult version, string apiUrl, string apiKey)
        {
            if (string.IsNullOrEmpty(apiUrl))
            {
                _log.Error("apiUrl canot be empty");
                return;
            }
            if (string.IsNullOrEmpty(apiKey))
            {
                _log.Error("apiKey canot be empty");
                return;
            }
            if (string.IsNullOrEmpty(projectName))
            {
                _log.Error("Project name canot be empty");
                return;
            }

            string octopusEnvironmentForDeploy = "UAT";

            _log.Information($"Deploying octopus release {version.FullVersion}");
            var settings = new OctopusDeployReleaseDeploymentSettings
            {
                SpecificMachines   = new[] { AutoDeployTarget },
                EnableDebugLogging = _log.Verbosity > Verbosity.Normal,
                //ShowProgress = true,
                //ForcePackageDownload = true,
                //WaitForDeployment = true,
                //DeploymentTimeout = TimeSpan.FromMinutes(1),
                //CancelOnTimeout = true,
                //DeploymentChecksLeepCycle = TimeSpan.FromMinutes(77),
                //GuidedFailure = true,
                //Force = true,
                //SkipSteps = new[] { "Step1", "Step2" },
                //NoRawLog = true,
                //RawLogFile = "someFile.txt",
                //DeployAt = new DateTime(2010, 6, 15).AddMinutes(1),
                //Tenant = new[] { "Tenant1", "Tenant2" },
                //TenantTags = new[] { "Tag1", "Tag2" },
            };
            var octoDeploy = new OctopusDeployReleaseDeployer(_fileSystem, _environment, _processRunner, _tools);

            octoDeploy.DeployRelease(apiUrl, apiKey, projectName, octopusEnvironmentForDeploy, version.FullVersion, settings);
            if (IsAppVeyor)
            {
                _appVeyorProvider.AddInformationalMessage($"Deployed to {octopusEnvironmentForDeploy} -  {AutoDeployTarget}");
            }
        }
        protected override void RunTool()
        {
            var tool = new OctopusDeployReleaseDeployer(FileSystem, Environment, ProcessRunner, Tools);

            tool.DeployRelease(Server, ApiKey, Project, DeployTo, ReleaseNumber, Settings);
        }