Writing/Assigning Value to Variables

Is it possible to write/assign values to VARIABLES created in Octopus from PowerShell script? I want to create variables which can easily be referenced in my deployment process steps and before the deployment starts I want to assign them based on type of installation, environment and some business requirements.

It would be nice if I can access variables I created and assign them dynamically.

Please help.

Thanks
Bhavesh

Hi Bhavesh,

Thanks for getting in touch! It looks like the best option available for this that we have would be to use our Output Variables feature/Prompted Variables.

I have posted links to our documentation below for both of these.
https://octopus.com/docs/deploying-applications/variables/output-variables
https://octopus.com/docs/deploying-applications/variables/prompted-variables

The Output variables option in Octopus gives you the ability to create dynamic variables in your scripts, the documentation has a lot of in depth information on how this works and how you can configure it.

The next idea is Prompted variables. Prompted variables are variables which you define values for at the time of deployment. You can create a variable and tag it as prompted, then when you deploy you are prompted to enter a value for said variable.

For assigning variables based on environment, you can use the scoping option. When you create your variable, you can assign a scope, that variable will only run when it is deploying to the environment it is scoped to.
For some more detailed information on scoped variables, we have the following documentation.
https://octopus.com/docs/deploying-applications/variables/scoping-variables

If you have any questions here or if I can provide you with any further information, please feel free to let me know. :slight_smile:

Best regards,

Thanks Daniel.

I am thinking to create one variable with JSON binding details and get value in Powershell using $OctopusParameters[“MyBindingJSON”] and create Output parameter based on app,environment, step.

Hope I am on right track.

Bhavesh

Hi Bhavesh,

Let me know how you go with this, if you run into any issues we are happy to help.

Best regards,
Daniel