Skip to content

Instantly share code, notes, and snippets.

@Damovisa
Last active August 29, 2015 14:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Damovisa/fb6dc48038a2c2ad9216 to your computer and use it in GitHub Desktop.
Save Damovisa/fb6dc48038a2c2ad9216 to your computer and use it in GitHub Desktop.
Get all parent and child steps for all projects
$octoBase = "http://octopusserver:port"
$apiKey = "API-XXXXXXXXXX"
Function GetFromOctopus([string]$relUrl) {
return Invoke-RestMethod -Uri "$octoBase$relUrl\?apiKey=$apiKey" -Method Get
}
$projects = GetFromOctopus -relUrl "/api/projects/all"
ForEach ($p in $projects.Items) {
$processLink = $p.Links.DeploymentProcess
$steps = GetFromOctopus $processLink
$stepCount = 0
$actionCount = 0
ForEach ($s in $steps) {
$stepCount += $s.Steps.Count
ForEach ($a in $steps.Steps) {
$actionCount += $a.Actions.Count
}
}
Write-Output "$($p.Name) has $stepCount top-level steps and $actionCount total steps"
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment