1

I'm working with Octopus and I need to add in one of my PowerShell scripts the chance to modify an Octopus Parameter (not Variable...). In few words, my website deploys in 2 folders, alternately, and I have to take a trace of this. My idea is to set a parameter that, at every run of the script reads the actual value and so knows where to deploy this new release.

I also tried some stuff such as

$OctopusParameters['Destination']=$Number

and

Set-OctopusVariable -Name 'Destination' -Value $Number

but without success.

I hope I've been clear enough and thanks in advance for everyone will reply.

Kernel
  • 105
  • 8
  • 1
    I've read this a couple of times and I'm not understanding what your goal is. Setting the `$OctopusParameters` will only have effect in your script. What do you want to use the value for? Where do you want to use it? – Swoogan Apr 24 '15 at 13:34
  • Hi, this variable represents a sort of global state that should be persistent through the deploys. It has the task of taking trace of the current folder in which my website is deployed - it will change between 2 everytime i deploy... Is now more clear? – Kernel Apr 24 '15 at 19:43

1 Answers1

4

You might want to try setting an environmental variable on the machine for this. It will persist between deployments.

Edit:

Can't format this in the comment very well, you probably want something like this

$destination = [environment]::GetEnvironmentVariable("Destination","Machine")

// change $destination to its opposite value

[Environment]::SetEnvironmentVariable("Destination",$destination,"Machine")
ryan.rousseau
  • 1,595
  • 1
  • 11
  • 22
  • Ok, I did this, but my goal is to modify this environmental variable at every deploy through the powershell script. – Kernel Apr 24 '15 at 19:44
  • Hi again, I tried to use the Set command, where I have to fill with Machine I put Machine's name in Environment, but seems not to recognize it. – Kernel Apr 27 '15 at 07:53
  • "Machine" is what you should use. It's the scope of the variable. The options are "Machine", "User", or "Process" – ryan.rousseau Apr 27 '15 at 12:57