private static IEnumerable<string> FormatReleasePropertiesAsStrings(Release release)
 {
     return new List<string>{
         "Version: " + release.Version,
         "Assembled: "+release.Assembled,
         "Package Versions: " + GetPackageVersionsAsString(release.PackageVersions),
         "Release Notes: " + ((release.ReleaseNotes != null) ? release.ReleaseNotes.Replace(System.Environment.NewLine,@"\n"): "")
     };
 }
    public static Deployment DeployRelease(this IOctopusSession session, Release release, DeploymentEnvironment environment, bool forceRedeploymentOfExistingPackages = false)
    {
        var deployment = new Deployment();
        deployment.EnvironmentId = environment.Id;
        deployment.ReleaseId = release.Id;
        deployment.ForceRedeployment = forceRedeploymentOfExistingPackages;

        return session.Create(release.Link("Deployments"), deployment);
    }
Exemplo n.º 3
0
    public static Release CreateRelease(this IOctopusSession session, Project project, IList<SelectedPackage> latestVersions, string version, string releaseNotes)
    {
        var release = new Release();
        release.Assembled = DateTimeOffset.UtcNow;
        release.AssembledBy = Environment.UserName;
        release.Version = version;
        release.SelectedPackages = latestVersions.ToArray();
        release.ReleaseNotes = releaseNotes ?? string.Empty;

        return session.Create(project.Link("Releases"), release);
    }
        void DeployRelease(Release release, DeploymentEnvironment environment)
        {
            var deployment = new Deployment();
            deployment.EnvironmentId = environment.Id;
            deployment.ReleaseId = release.Id;
            deployment.ForceRedeployment = Force;

            var result = Client.Create(release.Link("Deployments"), deployment).Execute();

            Log.InfoFormat("Successfully scheduled release '{0}' for deployment to environment '{1}'" + result.Name, release.Version, environment.Name);
        }
Exemplo n.º 5
0
    public static IEnumerable<string> GetDeployments(this IOctopusSession session, Release release, IEnumerable<DeploymentEnvironment> environments, bool force, ILog log)
    {
        var linksToDeploymentTasks = new List<string>();
        foreach (var environment in environments)
        {
            var deployment = session.DeployRelease(release, environment, force);
            var linkToTask = deployment.Link("Task");
            linksToDeploymentTasks.Add(linkToTask);

            log.InfoFormat("Successfully scheduled release {0} for deployment to environment {1}", release.Version, environment.Name);
        }
        return linksToDeploymentTasks;
    }
        IEnumerable<string> RequestDeployments(Release release, IEnumerable<DeploymentEnvironment> environments)
        {
            var linksToDeploymentTasks = new List<string>();
            foreach (var environment in environments)
            {
                var deployment = Session.DeployRelease(release, environment, Force);
                var linkToTask = deployment.Link("Task");
                linksToDeploymentTasks.Add(linkToTask);

                Log.InfoFormat("Successfully scheduled release '{0}' for deployment to environment '{1}'" + deployment.Name, release.Version, environment.Name);
            }
            return linksToDeploymentTasks;
        }
        Release CreateNewRelease(Project project, List<PackageVersion> latestVersions)
        {
            var version = VersionNumber;
            var releaseNotes = ReleaseNotes;
            if (string.IsNullOrWhiteSpace(version))
            {
                version = latestVersions.Select(p => SemanticVersion.Parse(p.Version)).OrderByDescending(v => v).First().ToString();
                Log.Warn("A --version parameter was not specified, so we will infer the version number from the packages. The highest version number is: " + version);
            }

            var release = new Release();
            release.Assembled = DateTime.UtcNow;
            release.AssembledBy = Environment.UserName;
            release.Version = version;
            release.ReleaseNotes = releaseNotes;
            release.PackageVersions = latestVersions.ToArray();

            Log.Debug("Creating release: " + version);

            var result = Client.Create(project.Link("Releases"), release).Execute();

            Log.Info("Release created successfully!");

            return result;
        }