Skip to content

Instantly share code, notes, and snippets.

@Dalmirog-zz
Created February 17, 2016 13:30
Show Gist options
  • Save Dalmirog-zz/1703f3b704eed5562e29 to your computer and use it in GitHub Desktop.
Save Dalmirog-zz/1703f3b704eed5562e29 to your computer and use it in GitHub Desktop.
Get Lifecycle phases info
##CONFIG
$OctopusURL = "" #Octopus URL
$OctopusAPIKey = "" #Octopus API Key
$LifecycleName = "" #Name of the Lifecycle you want to get info from
##PROCESS
$header = @{ "X-Octopus-ApiKey" = $env:OctopusAPIKey }
#1) Getting All the lifecycles
$AllLifecycles = Invoke-WebRequest $OctopusURL/api/lifecycles/all -Headers $header
#2) Getting the desired lifecycle by name
$Lifecycle = ($AllLifecycles.Content | ConvertFrom-Json) | ?{$_.name -eq $LifecycleName}
#3) Massage the Lifecycle object to show each phase on a table
$Table = @()
$PhaseCounter = 1
foreach($Phase in $Lifecycle.Phases){
$obj = [PSCustomObject]@{
LifecycleName = $Lifecycle.Name
PhaseNumber = $PhaseCounter
PhaseName = $Phase.Name
OptionalEnvironments = $Phase.OptionalDeploymentTargets
AutomaticEnvironments = $Phase.AutomaticDeploymentTargets
}
$Table += $obj
$PhaseCounter++
}
$Table
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment