How to update a single variable in an existing release

Hi,

This is what I’m trying to achieve. I have a load test env to which I deploy once a day. The build creates the whole environment and then tears it down once it is finished. This means that when a release is created I don’t know secrets/keys/etc for the load test env and I need to provide them to the release sepcific variable set later on. At the moment I simply update the main variable set and then update all variables in the variable set associated with a given release. This works but is not great as I’m putting values to Octopus main variable set that are valid only for a particular release. So I though the logical solution would be to update just a few variables directly in the release. Is that possible?

Thanks

Pawel

Hi Pawel,

Thanks for reaching out. Its not possible to update just a handful of variables. You can only update the entire Variable snapshot for a release.

Instead of updating static variables in your project, you could configure them as “prompt”. This way Octopus will ask you to set values for them before you start the deployment.

Hope that helps

Dalmiro

Hi Dalmiro,

This is fully automated process that runs at 3am so, unless I’m not fully understanding prompt variables, this approach is not going to work for me. Do you know if there is a plan to add that functionality?

Thanks

Pawel

Hi Pawel,

You could use Octo.exe to trigger the automated process (create release + deploy) and pass values to the prompt variables using to the parameter --variable

Dalmiro

Hi Dalmiro,

Sorry for the delay. I somehow missed the notification.
Are prompt variables stored somewhere so they can be inspected later when something goes wrong ?

Regards

Pawel

Hi Pawel,

No worries about the delay! If you enable the debugging variables OctopusPrintVariables and OctopusPrintEvaluatedVariables, each variable and its value will be printed on the deployment raw log, where you can inspect them if something goes wrong.

Regards,

Dalmiro

These are keys, so it might not be a good idea to include them in the logs.
Thanks a lot for you help. Prompt variables are an option but for now I will stick with updating main variables and then pushing them back to the release. It would nice to have to ability to update variables directly in the release.

Thanks

Pawel

Hi Pawel,

There’s a project called Octoposh that I started, which includes a bunch of Powershell cmdlets to automate Octopus’ tasks using the API. One of the cmdlets its called Update-OctopusReleaseVariableSet which is the code equivalent of hitting the “Update variables button”.

That script, combined with another one I’ll be finishing this weekend which will allows you to add/update variables might be able to help you automate this process. It should be something like this:

  1. You create the Release programatically
  2. Use the new cmdlet to update your keys on your project’'s variable set
  3. Use Update-OctopusReleaseVariableSet to inject the updated variables into the release.
  4. Deploy the release


Do you think this might work for you?

Thanks,

Dalmiro

Great project! I wish I knew a bit earlier about it as I already implemented the solution using the .net client. I will definitively give it a try next time I need to get access to Octopus from Powershell.

Pawel

Hi Pawel,

I just wanted to let you know that I’ve released a new version of Octoposh (0.2.69) with a stable version of Update-OctopusVariableSet. Check this link to learn how to use it

I encourage you to create a test project first and try the command until you fully understand how it works.

As this is a separate project from Octopus, please report any bugs/ask any questions on the project’s gitter channel https://gitter.im/Dalmirog/OctoPosh

Next time you need to do something with Octopus from Powershell, shoot me an email to support@OctopusDeploy.com , perhaps I’ve already built something for it or its something I can add to Octoposh.

Thanks!

Dalmiro

Thank you!