Created
February 17, 2016 13:30
-
-
Save Dalmirog-zz/1703f3b704eed5562e29 to your computer and use it in GitHub Desktop.
Get Lifecycle phases info
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
##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