Last active
August 29, 2015 14:18
-
-
Save Dalmirog-zz/7376debddbf86d59e627 to your computer and use it in GitHub Desktop.
Deploy last release of specific Project/Environment to a set a machines
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
#Configuration. All variables inside this section are mandatory. | |
$octopus_url = "http://localhost" | |
$octopus_apikey = "API-YHMOPNVMRLFXJBV4EQWWFKXAWLQ" | |
$header = @{"X-Octopus-ApiKey"="$octopus_apikey"} | |
$OctoExePath = "C:\Tools\Octo.exe" | |
$EnvironmentName = "MyEnvironmentName" | |
$ProjectName = "MyProjectName" | |
$machines = "MyMachinename1,MyMachinename2" | |
#Getting Environment | |
$AllEnvironments = Invoke-RestMethod $octopus_url/api/environments/all -Method Get -Headers $header -Verbose | |
$Environment = $AllEnvironments | ?{$_.name -eq "$EnvironmentName"} | |
#Getting Project | |
$AllProjects = Invoke-RestMethod $octopus_url/api/Projects/all -Method Get -Headers $header -Verbose | |
$Project = $AllProjects | ?{$_.name -eq "$ProjectName"} | |
#Getting last release deployed on project $project to the environment $Environment | |
$LastRelease = (Invoke-RestMethod -Uri "$octopus_url/api/dashboard/dynamic?environments=$($environment.ID)&projects=$($project.ID)" -ContentType application/json -Headers $header -Method Get -Verbose).items | |
#Calling Octo.exe with all the info gathered | |
& $OctoExePath --Server=$octopus_url --apikey=$octopus_apikey --specificmachines=$Machines --deployto=$($Environment.name) --releaseNumber=$($LastRelease.releaseversion) --progress |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment