Get_octopusvariable

Hi.

Is it possible to get all Project variables (keys?) via get_octopusvariable from deployment script (https://octopus.com/docs/deployment-examples/custom-scripts/using-variables-in-scripts)?

Thanks.

Hi @drubtcov,

Thanks for reaching out.

Do you mean you’d like to have 1 object that has all of the variables of a project within it?

I believe you will need to achieve this with API calls.

Here is an example in PowerShell that has some functions for getting the project variables: https://github.com/OctopusDeploy/OctopusDeploy-Api/blob/master/REST/PowerShell/Variables/AddOrEditVariablesWithScoping.ps1

I believe you should be adapt the logic above if you want to stick with bash/python.

As always, please thoroughly read any scripts we give you and test it before putting it in production as our scripts are not guaranteed to work in all scenarios.

Please let me know if that helps you get where you need to go, or if I misunderstood and we need to dig in a bit further.

Thanks,
Jeremy

1 Like

Hi @drubtcov,

I also remembered that since you are using this in a deployment, you will likely want to use the variable snapshot and not the project variables as the project variables may have changed since you created the release. Potentially not, though. I definitely wanted to let you know of both options.

Please let me know how it goes.

Thanks,
Jeremy

Hi.
Thank you for advice. We will try to work through the API.

Hi @drubtcov,

You’re very welcome! Please let me know if you run into any issues and need a hand.

I hope you have a great rest of your week.

Best,
Jeremy

This topic was automatically closed 31 days after the last reply. New replies are no longer allowed.