Created
August 23, 2015 21:34
-
-
Save Dalmirog-zz/2bb38787f11c9cacabf8 to your computer and use it in GitHub Desktop.
Adding variable to variable 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
| ####Adding a new variable##### | |
| $variableset = Get-OctopusVariableSet -Projectname Powershell -ResourceOnly | |
| $newvariable = New-Object Octopus.Client.Model.VariableResource | |
| $scope = New-Object Octopus.Platform.Model.ScopeSpecification | |
| #Environment Scope | |
| #$scope.Add([Octopus.platform.Model.Scopefield]::Environment,(New-Object Octopus.Platform.Model.ScopeValue("Environments-1"))) | |
| #Machine Scope | |
| #$scope.Add([Octopus.platform.Model.Scopefield]::Machine,(New-Object Octopus.Platform.Model.ScopeValue("Machines-1"))) | |
| #Step Scope | |
| #$scope.Add([Octopus.platform.Model.Scopefield]::Action,(New-Object Octopus.Platform.Model.ScopeValue("9a2259a9-71b4-4f09-bb3a-85217b5848f8"))) | |
| #Role Scope | |
| #$scope.Add([Octopus.platform.Model.Scopefield]::Role,(New-Object Octopus.Platform.Model.ScopeValue("WebServer"))) | |
| $prompt = New-Object Octopus.Platform.Model.VariablePromptOptions | |
| $prompt.Description = "PromptDescription" | |
| $prompt.Label = "PromptLabel" | |
| $prompt.Required = $false | |
| $newvariable.Name = "newVariable" | |
| $newvariable.Value = "Value" | |
| $newvariable.IsEditable = $true | |
| $newvariable.IsSensitive = $false | |
| $newvariable.Prompt = $null # make this = to $null if you dont want a prompt for this variable | |
| $newvariable.Scope = $scope | |
| $variableset.Variables.Add($newvariable) | |
| Update-OctopusResource -Resource $variableset -Force |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment