예제 #1
0
    public static IList <DeploymentEnvironment> FindEnvironments(this IOctopusSession session, ICollection <string> environmentNames)
    {
        if (environmentNames == null || !environmentNames.Any())
        {
            return(new List <DeploymentEnvironment>());
        }

        var list         = new List <DeploymentEnvironment>();
        var environments = session.List <DeploymentEnvironment>(session.RootDocument.Link("Environments"));

        foreach (var environmentName in environmentNames)
        {
            if (string.IsNullOrWhiteSpace(environmentName))
            {
                continue;
            }

            var environment = environments.FirstOrDefault(x => string.Equals(x.Name, environmentName, StringComparison.InvariantCultureIgnoreCase));
            if (environment == null)
            {
                throw new ArgumentException(string.Format("An environment named '{0}' could not be found.", environmentName));
            }

            list.Add(environment);
        }

        return(list);
    }
예제 #2
0
    public static Project GetProject(this IOctopusSession session, string projectName)
    {
        var projects = session.List <Project>(session.RootDocument.Link("Projects"));

        var project = projects.FirstOrDefault(x => string.Equals(x.Name, projectName, StringComparison.InvariantCultureIgnoreCase));

        if (project == null)
        {
            throw new ArgumentException(string.Format("A project named '{0}' could not be found.", projectName));
        }

        return(project);
    }
예제 #3
0
    public static Release GetRelease(this IOctopusSession session, Project project, string version)
    {
        var releases = session.List <Release>(project.Link("Releases"));

        var release = releases.FirstOrDefault(x => string.Equals(x.Version, version, StringComparison.InvariantCultureIgnoreCase));

        if (release == null)
        {
            throw new ArgumentException(string.Format("A release named '{0}' could not be found.", version));
        }

        return(release);
    }
예제 #4
0
    public static SelectedPackage GetLatestPackageForStep(this IOctopusSession session, Step step)
    {
        var versions = session.List <PackageVersion>(step.Link("AvailablePackageVersions"));

        var latest = versions.FirstOrDefault();

        if (latest == null)
        {
            throw new Exception(string.Format("There are no available packages named '{0}'.", step.NuGetPackageId));
        }

        return(new SelectedPackage {
            StepId = step.Id, NuGetPackageVersion = latest.Version
        });
    }
예제 #5
0
    public static SelectedPackage GetPackageForStep(this IOctopusSession session, Step step, string version)
    {
        var versions = session.List <PackageVersion>(step.Link("AvailablePackageVersions"));

        var latest = versions.Where(s => (s.Version == version)).First();

        if (latest == null)
        {
            throw new Exception("There are no available packages named '{0}'");
        }

        return(new SelectedPackage {
            StepId = step.Id, NuGetPackageVersion = latest.Version
        });
    }
예제 #6
0
    public static Release GetRelease(this IOctopusSession session, Project project, string version)
    {
        var releases = session.List <Release>(project.Link("Releases"));

        Release release;

        if (version.ToLower() == "latest")
        {
            release = releases.OrderByDescending(r => SemanticVersion.Parse(r.Version)).FirstOrDefault();
        }
        else
        {
            release = releases.FirstOrDefault(x => string.Equals(x.Version, version, StringComparison.InvariantCultureIgnoreCase));
        }
        if (release == null)
        {
            throw new ArgumentException(string.Format("A release named '{0}' for project '{1}' could not be found.", version, project.Name));
        }
        return(release);
    }
예제 #7
0
 public static IList <DeploymentEnvironment> ListEnvironments(this IOctopusSession session)
 {
     return(session.List <DeploymentEnvironment>(session.RootDocument.Link("Environments")));
 }
예제 #8
0
 public static IList <Release> GetReleases(this IOctopusSession session, Project project, int skip, int take)
 {
     return(session.List <Release>(project.Link("Releases"), new QueryString {
         { "skip", skip }, { "take", take }
     }));
 }
예제 #9
0
 public static IList <Step> FindStepsForProject(this IOctopusSession session, Project project)
 {
     return(session.List <Step>(project.Link("Steps")));
 }
예제 #10
0
 public static IEnumerable <Deployment> GetMostRecentDeployments(this IOctopusSession session, Project project)
 {
     return(session.List <Deployment>(project.Link(("RecentDeployments"))));
 }
예제 #11
0
 public static IList <Project> ListProjects(this IOctopusSession session)
 {
     return(session.List <Project>(session.RootDocument.Link("Projects")));
 }