Created
April 5, 2018 05:01
-
-
Save dennisroche/74ce317a33d9d521d5132b937f1f0125 to your computer and use it in GitHub Desktop.
Octopus Deploy script to shift a range of projects to the right (dev to staging) as a set
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
$octo = Get-OctopusTools | |
Write-Heading 'Projects' | |
function GetProjectsInGroup([string]$projectGroupName, [string]$ignoreProjectNames) { | |
$projectGroup = Invoke-OctopusApi '/api/projectgroups/all' | Where-Object { $_.Name -eq $projectGroupName } | |
if ($null -eq $projectGroup) { | |
Write-Fatal "Project $projectGroupName not found" | |
} | |
Write-Host "Project Group: $($projectGroup.Name)" | |
Write-Verbose "`t$($this.BaseUrl)$($projectGroup.Links.Self)" | |
$comparisonArray = $ignoreProjectNames.Split("`n") | % Trim | |
Write-Host "Skipping: $comparisonArray" | |
$projects = Invoke-OctopusApi "/api/projects/all" | Where-Object { $_.ProjectGroupId -eq $projectGroup.Id -and $_.Name -notin $comparisonArray } | |
$projects | ForEach-Object { | |
Write-Host "- $($_.Name)" | |
} | |
$projects | Write-Output | |
} | |
$projects = GetProjectsInGroup $ProjectGroupName $IgnoreProjects | |
$projects | ForEach-Object { | |
# Release Promotion | |
# https://octopus.com/docs/api-and-integration/octo.exe-command-line/promoting-releases | |
$projectName = $_.Name | |
Write-Heading "$projectName" | |
Write-Host "Promoting '$projectName' from $PromoteFrom to $PromoteTo" | |
& $octo promote-release --project=$projectName --from=$PromoteFrom --to=$PromoteTo --tenant=* --server=$OctopusUrl --apiKey=$OctopusApiKey --updateVariables | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment