Substitute Variables with Octopus system variables

Hi,

Is it possible to reference an Octopus system variable with substitution variables. I have a sys.ini file which has a section for server names. It just needs to be the deployment server name so saves me writing out 100s of server names in the variable.

Would I be able to set the ini file as

Server=#{ServerName}

Then the variable for that project be ServerName - Value = $OctopusParameters[“Octopus.Machine.Name”]

Appreciate the help

Thanks,

Dan

Hey @daniel.witter

Yes, it’s certainly possible to reference octopus system variables with substitution variables. We sometimes refer to it as composite variables, as you are effectively composing variables from other variables :grinning_face_with_smiling_eyes:

To achieve what you want, you would do something like this in the project variables:

In your ini file, you would have as you already mentioned;

Server=#{ServerName}

I suspect you already know but in order for Octopus to know you want .ini files replaced using Octopus variables, you need to let it know in the Variable Substitution section, something like this should work:

I hope that helps!

Best regards,
Mark

Thank You!

Hey @daniel.witter

You’re very welcome!

Mark.

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