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); }
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); }
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); }
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 }); }
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 }); }
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); }
public static IList <DeploymentEnvironment> ListEnvironments(this IOctopusSession session) { return(session.List <DeploymentEnvironment>(session.RootDocument.Link("Environments"))); }
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 } })); }
public static IList <Step> FindStepsForProject(this IOctopusSession session, Project project) { return(session.List <Step>(project.Link("Steps"))); }
public static IEnumerable <Deployment> GetMostRecentDeployments(this IOctopusSession session, Project project) { return(session.List <Deployment>(project.Link(("RecentDeployments")))); }
public static IList <Project> ListProjects(this IOctopusSession session) { return(session.List <Project>(session.RootDocument.Link("Projects"))); }