I am trying to use “variable substitute in Json” plugin/feature to replace multiple values based on the role and environment defined in the scope for few of the variables.
But when I run this step as part of process, none of the values are replaced with the variable defined. I have 3 variables defined for name_key, category_key, path_key but none of them is getting replaced in the json file.!
It looks like the syntax in your example is from the substitute variables in templates feature but you mentioned that you’re using the structured configuration variables feature. You’ll need to use the substitute variables in templates feature for this work with your example syntax.
I hope this is helpful. Please let us know if you have any questions.
Thanks for the prompt reply. I dont see template option of structured configuration variable feature in Octopus. Since I have 2 data subset in my json and I only want to substitute variables for only 1 of the subset, I am not sure how to pass the octopus variable name for the below source.
The other thing to note is that I am not using structural variables template as it comes with IIS deployment and in my case, I am only having a step to substitute some variables in the json file located in my deployment server.
Would you be able to share a little more detail about how your deployment process is configured? In particular, is the JSON file deployed as part of a package or does it come from some other source?
The json file is downloaded from Blob to the deployment target and then I am trying to substitute variables for that json file based on the environment and role defined in the scope in Project Variables as per screenshot attached .
Thank you for getting back to me with the details.
I’m working on reproducing this locally so I can make a recommendation. I’ll get back to you once I have an update. In the meantime, could you let me know which version of Octopus server you are running?
That’s a fairly old version of Octopus Deploy and it lacks some of the features of the newer versions that might be helpful with meeting your requirements. I’d recommend upgrading to a newer version if possible.
The newer versions of Octopus Deploy have the “Substitute variables in templates” feature available which I believe would solve this for you. You would be able to add a “Run a script” step, with a basic placeholder script as content, and use the variable substitution on the JSON file:
You can read more about how this works and find step by step instructions in the attached article (use the “Run a script” step in place of the “Deploy a package” step):
I hope this is helpful. Please let me know if you have any questions.