Beispiel #1
0
 public void SetNextVersion(VersionResult version)
 {
     _log.Information($"Building {version.FullVersion}");
     if (IsInteractiveBuild)
     {
         _log.Information($"Interacitve Build Mode");
     }
     else if (IsAppVeyor)
     {
         _appVeyorProvider.UpdateBuildVersion(version.FullVersion);
         _appVeyorProvider.AddInformationalMessage($"Building {version.FullVersion}");
     }
 }
Beispiel #2
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}");
            }
        }
Beispiel #3
0
        public void CreateOctopusRelease(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;
            }
            _log.Information($"Creating octopus release {version.FullVersion}");
            var settings = new CreateReleaseSettings
            {
                EnableDebugLogging    = _log.Verbosity > Verbosity.Normal,
                EnableServiceMessages = false,               // Enables teamcity services messages when logging
                ReleaseNumber         = version.FullVersion,
                DefaultPackageVersion = version.FullVersion, // All packages in the release should be x.x.x.x
                // One or the other
                ReleaseNotes = CommitMessageShort,
                //ReleaseNotesFile = "./ReleaseNotes.md",
                Server = apiUrl,
                ApiKey = apiKey
                         //IgnoreExisting = true // if this release number already exists, ignore it
                         //ToolPath = "./tools/OctopusTools/Octo.exe"
                         //IgnoreSslErrors = true,
                         //Packages = new Dictionary<string, string>
                         //            {
                         //                { "PackageOne", "1.0.2.3" },
                         //                { "PackageTwo", "5.2.3" }
                         //            },
                         //PackagesFolder = @"C:\MyOtherNugetFeed",
            };
            var octoRelease = new OctopusDeployReleaseCreator(_fileSystem, _environment, _processRunner, _tools);

            octoRelease.CreateRelease(projectName, settings);

            if (IsAppVeyor)
            {
                _appVeyorProvider.AddInformationalMessage($"Octopus release {version.FullVersion} created.");
            }
        }
Beispiel #4
0
        public void PatchAllAssemblyInfo(VersionResult versionInfo, string copyrightText)
        {
            var parser        = new AssemblyInfoParser(_fileSystem, _environment);
            var creator       = new AssemblyInfoCreator(_fileSystem, _environment, _log);
            var assemblyFiles = _globber.GetFiles("./**/AssemblyInfo.cs");

            foreach (var file in assemblyFiles)
            {
                _log.Verbose($"Possibly file to patch:{file}");
                if (file.ToString().Contains("packages/"))
                {
                    continue;
                }
                var assemblyInfo = parser.Parse(file);

                string rootVersion = versionInfo.RootVersion;
                //on AppVeyor, if it is a PullRequest and "pull_requests: do_not_increment_build_number" is true, it will make up a build like 1.0.2-fisiek
                //It does this because it requires unique version numbers.
                //So, what is in RootVersion has this 'prerelease' tag of 'fisiek' or whatever on it.  This is not valid when versioning assembiles!
                //we of course are not going to publish prereleases to nuget, so just make up any version for this.

                //if do_not_increment_build_number is false, then the version does NOT contain the extra tag and it does not matter.
                //of course we do not know if this is true or false.  So we will just look...
                if (IsPullRequest && rootVersion.Contains("-"))
                {
                    rootVersion = "1.0.1";
                }

                _log.Information($"Creating File Version:{rootVersion} Info Version:{versionInfo.FullVersion} for {file} ");

                creator.Create(file, new AssemblyInfoSettings
                {
                    Product              = assemblyInfo.Product,
                    Version              = rootVersion,
                    FileVersion          = rootVersion,
                    InformationalVersion = versionInfo.FullVersion,
                    Copyright            = string.Format(copyrightText, DateTime.Now.Year)
                });
            }
        }
Beispiel #5
0
        public void DeployOctopusRelease(VersionResult version)
        {
            string octopusApiHttp     = _environment.GetEnvironmentVariable("Octopus.ApiHttp");
            string octopusApikey      = _environment.GetEnvironmentVariable("Octopus.PublishApiKey");
            string octopusProjectName = _environment.GetEnvironmentVariable("Octopus.ProjectName");

            if (string.IsNullOrEmpty(octopusApiHttp))
            {
                _log.Error("Must define Octopus.ApiHttp environment variable to use OctopusDeploy functions");
                return;
            }
            if (string.IsNullOrEmpty(octopusApikey))
            {
                _log.Error("Must define Octopus.PublishApiKey environment variable to use OctopusDeploy functions");
                return;
            }
            if (string.IsNullOrEmpty(octopusProjectName))
            {
                _log.Error("Must define Octopus.ProjectName environment variable to use OctopusDeploy functions");
                return;
            }
            DeployOctopusRelease(octopusProjectName, version, octopusApiHttp, octopusApikey);
        }
Beispiel #6
0
        public VersionResult GetNextVersion(string defaultVersion)
        {
            var result = new VersionResult
            {
                RootVersion  = GetBaseVersionString(defaultVersion),
                IsPreRelease = IsPreRelease
            };

            if (IsPreRelease)
            {
                string extraLabel = "-" + Branch.Replace("_", "");
                if (extraLabel.Length > 20)
                {
                    extraLabel = extraLabel.Substring(0, 20);
                }
                _log.Verbose($"PreRelease detected:{extraLabel}");
                result.FullVersion = result.RootVersion + extraLabel;
            }
            else
            {
                result.FullVersion = result.RootVersion;
            }
            return(result);
        }