Created
August 11, 2014 02:30
-
-
Save mbenford/3db1137e183c93baf0fa to your computer and use it in GitHub Desktop.
Powershell script for TeamCity that creates and deploys multiple releases on Octopus Deploy
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
function Build-Arguments($project) { | |
$args = @() | |
$args += "create-release" | |
$args += "--server=%octopus.url%" | |
$args += "--apikey=%octopus.apikey%" | |
$args += "--project=$project" | |
$args += "--version=%octopus.releaseNumber%" | |
$args += "--deployto=%octopus.deployTo%" | |
$args += "--packageversion=%octopus.packageVersion%" | |
$args += "--force" | |
$args += "--enableservicemessages" | |
$args += "--progress" | |
if ("%octopus.waitForDeployment%" -eq "true") { | |
$args += "--waitfordeployment" | |
} | |
return $args | |
} | |
function Secure-Sensitive-Data { | |
return $input -Replace "(--apikey)(=.*)$", '$1 SECRET' | |
} | |
$octo = Join-Path -Path "%teamcity.tool.octopus%" -ChildPath "octo.exe" | |
"%octopus.projects%".split(",") | ForEach-Object { | |
$project = $_.trim() | |
$args = Build-Arguments $project | |
Write-Host "--" | |
Write-Host "Deploying $project..." | |
Write-Host "Executing octo.exe..." | |
Write-Host "source : $octo" | |
Write-Host "arguments:", ($args | Secure-Sensitive-Data) | |
& $octo $args | Out-String | |
if (-Not $?) { | |
Exit $LASTEXITCODE | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment