Can we parse a text file or json which have all variables in octo.exe CLI

Hi,

Currently we are adding our variable values in Octopus GUI Project–>Variables section.

But we want to put all these variables in either json or text file and put this in SCM along with code.

Can we call this variable file in Octo.exe CLI to substitute the values depending on environments.

Please let me know if it is possible.

Regards,
Satish

Hello Satish,

Thanks for getting in touch. Currently the only way to achieve what you’re after is to use Octopus.Client .NET library to update variables, here’s the documentation for it: https://octopus.com/docs/api-and-integration/octopus.client

A good way to get started will be to open the network tab on your browser and do some variable changes via the UI and see what calls are made, you’ll need to write code C#/powershell/etc to do the actions you are after to update the state of the variables in Octopus.

Let us know if you hit any specific issues, comparing your calls to those generated by the UI will be your best bet to write/debug your variable manipulation code.

Regards,
Nick

Hi Nick,

Thanks for your reply, will follow the document and do it from our end.

I will get back to you if I stuck somewhere in this process.

Regards,
Satish

Hi Nick,

I have created a poweshell script to get the values from csv file and create variables with respect Name,Value and scope.
Now if I add new variable name,value and scope in the same csv and execute same ps1 all variables are creating again and I can see duplicate values from Octopus UI.
I need some logic in ps1 which ignore to create variables already exist in variableset, and create only new variable which are not in variableset when iterating the csv file.
please find my script and csv file. Can you help me on this.

Regards,
Satish
satish.csv (396 Bytes)
vars.ps1 (1.7 KB)

Hi Nick,

I modified the script, now it is working as expected.

Regards,
Satish

1 Like

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