Last active
April 6, 2016 13:30
-
-
Save DamianMac/00c4b7ccac698b200f13 to your computer and use it in GitHub Desktop.
Query and Update Octopus Deploy projects and lifecycles
This file contains 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
$server = " http://yourserver/" #your octopus server | |
$apiKey = "API-YOURAPIKEY" #you'll need to generate an API | |
$command = $($server + "/api/projects") | |
$projects = Invoke-RestMethod -Method Get -Uri $command -Header @{"X-Octopus-ApiKey"=$apiKey} | |
$projects.Items | Format-Table Id, Name, lifecycleId | |
$command = $($server + "/api/lifecycles") | |
$lifecycles = Invoke-RestMethod -Method Get -Uri $command -Header @{"X-Octopus-ApiKey"=$apiKey} | |
$lifecycles.Items | Format-Table Id, Name |
This file contains 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
$server = " http://yourserver/" #your octopus server | |
$apiKey = "API-YOURAPIKEY" #you'll need to generate an API | |
$command = $($server + "/api/projects/Projects-106") #use the project ID from the earlier query as the URL | |
$project = Invoke-RestMethod -Method Get -Uri $command -Header @{"X-Octopus-ApiKey"=$apiKey} | |
$project.LifecycleId = "Lifecycles-120" #use the lifecycle ID from the earlier query and change this to the one you want | |
$body = $project | ConvertTo-Json | |
$new = Invoke-RestMethod -Method Put -Uri $command -Body $body -Header @{"X-Octopus-ApiKey"=$apiKey} | |
#run this then run the previous query and you should see it all fixed up |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment