Skip to content

Instantly share code, notes, and snippets.

@hnrkndrssn
Created September 29, 2015 05:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save hnrkndrssn/c9f42161d730cb32daf6 to your computer and use it in GitHub Desktop.
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
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);
}
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