Created
September 29, 2015 05:59
-
-
Save hnrkndrssn/c9f42161d730cb32daf6 to your computer and use it in GitHub Desktop.
Create library variable set to disable delta compression and add it to all projects in an Octopus instance
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
var octopusUrl = "http://octopus.url"; | |
var apiKey = "API-xxxxxxxxxxxxxxxxxxxxxxxxxx"; | |
var octopusServer = new Octopus.Client.OctopusServerEndpoint(octopusUrl, apiKey); | |
var repo = new Octopus.Client.OctopusRepository(octopusServer); | |
var newLibraryVariableSet = new Octopus.Client.Model.LibraryVariableSetResource(); | |
newLibraryVariableSet.Name = "Skip Delta Compression"; | |
newLibraryVariableSet.Description = "Provides a shared variable set to skip delta compression that can be included on projects that shouldn't use it."; | |
var skipDeltaCompressionVariableSet = repo.LibraryVariableSets.Create(newLibraryVariableSet); | |
var newVariableSet = repo.VariableSets.Get(skipDeltaCompressionVariableSet.VariableSetId); | |
newVariableSet.Variables.Add(new Octopus.Client.Model.VariableResource { Name = "Octopus.Acquire.DeltaCompressionEnabled", Value = "false" }); | |
var variableSet = repo.VariableSets.Modify(newVariableSet); | |
var projects = repo.Projects.GetAll(); | |
foreach(var projectRef in projects) | |
{ | |
var project = repo.Projects.Get(projectRef.Id); | |
project.IncludedLibraryVariableSetIds.Add(skipDeltaCompressionVariableSet.Id); | |
repo.Projects.Modify(project); | |
} |
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
Add-Type -Path 'C:\Program Files\Octopus Deploy\Octopus\Octopus.Client.dll' | |
$baseUri = "http://octopus.url" | |
$apiKey = "API-xxxxxxxxxxxxxxxxxxxxxxxxx" | |
$endpoint = New-Object Octopus.Client.OctopusServerEndpoint $baseUri, $apiKey | |
$repository = New-Object Octopus.Client.OctopusRepository $endpoint | |
$newLibraryVariableSet = New-Object Octopus.Client.Model.LibraryVariableSetResource | |
$newLibraryVariableSet.Name = "Skip delta compression" | |
$newLibraryVariableSet.Description = "Provides a shared variable set to skip delta compression that can be included on projects that shouldn't use it." | |
$skipDeltaCompressionVariableSet = $repository.LibraryVariableSets.Create($newLibraryVariableSet) | |
$newVariable = New-Object Octopus.Client.Model.VariableResource | |
$newVariable.Name = "Octopus.Acquire.DeltaCompressionEnabled" | |
$newVariable.Value = "false" | |
$newVariableSet = $repository.VariableSets.Get($skipDeltaCompressionVariableSet.VariableSetId) | |
$newVariableSet.Variables.Add($newVariable) | |
$repository.VariableSets.Modify($newVariableSet) | |
$projects = $repository.Projects.GetAll() | |
$projects | % { | |
$project = $repository.Projects.Get($_.Id) | |
$project.IncludedLibraryVariableSetIds.Add($skipDeltaCompressionVariableSet.Id) | |
$repository.Projects.Modify($project) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment