Variable Multi line Value

Hi,

I was looking for an easy way of managing hostnames for binding using variables.

Is there any way to access variables value by index?

Let’s say I have Variable named “XYZHostname” and below are the values






Now I want to know how can I access these values using the variable in step template under binding and I want to selective value.

Hi,

Thanks for getting in touch! Have you tried using the Drop down option for control type in your step template parameters?

I have attached a couple of screenshots that illustrate how this is configured and used. The first being the parameters section on the step templates, second the step being used in a project.

Let me know if this helps, or if you have any further questions.

Best regards,
Daniel

Hi Daniel,

This solution might work for me. Can you please let me know how can I add parameter in “Deploy an IIS Web Site” template as I dont see any way to add parameters in this template or any template which is provided by Octopus Deploy and comes pre-installed.

EDIT: nevermind, I found the option to do it. Let me try it and will come again if I need any further help.

Thanks,
Imran

This is not working for me. This option will give another step but I want something like variables which I can define with Multiline Value and use it in existing step template “Deploy an IIS Web Site” and then under IIS Bindings -> Add binding -> Hostname Field with the scenarios I explained in my initial question. Giving more details below:

“HostName” Variable will have below value:






and then I would like to access it by giving index Hostname[0], HostName[1], HostName[2] and so on.

Please let me know if you need more info.

Thanks,
Imran

Hi Imran,

Thanks for getting back. I see what you are after now. And I believe there is a more streamlined approach we can take here. While list values can work to some degree in Octopus, I think you are overlooking the scoping function we have. (Sorry if I am sill misinterpreting what you need here)

The variable scoping option will let you create multiple variable with the same name and different values in your project. As an example.

Variable Name | Variable Value
XYZHostname | xyz.com
XYZHostname | abc.com
XYZHostname | jkl.com

After creating those three values, you can set their scope to where the value is needed. For example, you may have TentacleXYZ, TentacleABC, TentacleJKL, you could scope each of the above to their respective target and simply call #{XYZHostname} in your step under Hostname. When the project is deployed, it will evaluate this variable to its respective scoping, giving the correct server its desired value.

Our documentation has some more information on this: https://octopus.com/docs/deploying-applications/variables/scoping-variables

However, if it is specifically a list format, or index replacement, the following documentation has some relevant information for you. However, from the looks of it you require scoping.

Please let me know if the above helps or if you have any further questions.

Best regards,
Daniel

Hi Daniel,

I have used scoping in my all projects and it’s not I’m looking for and yes, I’m specifically looking for list format in variable or index replacement as I have big list of host names so dont want to put the same effort in creating variables for each host name as the same effort will be required to put those host names in IIS Binding step in the process template.

I’m looking for some better solution to manage it more efficiently. I know its a one time effort to put all those host names in IIS binding step but what if I want to remove any host name or add any host name or move all or some of the host names to another site, for this I’ll have to touch the process step which I want to avoid to minimize the risk of any mistake there.

If I’ll have the variable with the list index (like an array) then it will be a lot easier to manage it.

Also, I see you have mentioned in your last reply about the link of documentation on index replacement but there is no link.

Thanks,
Imran

Hi Imran,

Sorry, I didn’t double check that the link was attached. https://octopus.com/docs/reference/variable-substitution-syntax#VariableSubstitutionSyntax-IndexReplacement

However, after reading your response, I do not believe what you are after exists. Our variable substitution syntax allows for index replacement, however this is more dictionary style, you can define something like this:

Var1[bob] | Password1
Var1[dave] | Password2
User | bob

#{Var1[#{User}} evaluates to Password1

So I do not believe this is what you are after. We do not offer a direct array option to have multiple values for the same variable and call them by their position. Our solution for this is to use scoping as mentioned before. If you are interested in seeing a feature like this added into Octopus, I believe the best idea would be to check out our UserVoice suggestions page. You are able to create suggestion, vote and comment on other suggestions. Once we can see enough community support for one, we can start looking into its implementation. https://octopusdeploy.uservoice.com/

Sorry that I could not be of more help here.

Best regards,
Daniel