Variable scope using tags and environments

I am in the process of configuring our octopus deploy to multi-tenancy and I have run into an issue with variables. I have a variable called domain name that is created on the depending on which server the site is running on etc. The current scope of this variable is per environment (site), obviously this is not going to work for multi-tenancy. My thinking is to use a mixture of tags and environment to get around this issue. I’ll explain if that makes no sense:

Say I have two tenants named T1 and T2 (both are different companies so will be hard to change the naming convention of one of them), both have a production and test environment. Obviously the domain name for each site will be different, the naming convention in T1 is test-mysite if it is a test site, and just mysite for a production one. T2 however has the naming convention: mysite-test if it is a test site and mysite if it is production.
To make sure the correct name convention is used, I have created an Environment Naming variable set. I have one variable with the value of test- and the other with -test. The test- variable has the scope of: Test environment and a T1 specific tag. The -test variable has the scope of: Test Environment and a T2 specific tag.

Is Octopus able to handle this so that the variable is only attached the specific tenant or with it read the variable as being attach to the Test Environment and ignore the tag?

Hi Tim,
If I understand your scenario correctly, it sounds like you may be able to benefit from some of the other changes that were brought to variables with the introduction of multi-tenancy. As outlined in this documentation, what you can do is set up some variable templates on your project. These variable templates define values that must be provided by any tenants who deploy this project. When you then go to the variables tab for your tenant, you should then see a set of fields that correspond to the variables you configured for this project, duplicated for each environment that the tenant is linked to. You can then configure each of your tenant variables differently for each environment. So given some normal project variable #{SiteName} in the project variables grid, you could do something like

Test Production
Tenant1 test-#{SiteName} #{SiteName}
Tenant2 #{SiteName}-test #{SiteName}

To get what you are after.
Or if you have lots of tenants that and you wish to reduce the duplication, you could go even further with the variable pattern replacement approach and have just PreName = "test-#{SiteName}", PostName = "#{SiteName}-test" and then just assign the tenant variables as PreName, PostName or SiteName as appropriate. The sky is the limit with these variables!

Let me know if this information helps your scenario, or if I may have mis-interpreted what you are after. Once again further documentation available at http://docs.octopusdeploy.com/display/OD/Working+with+tenant-specific+variables will provide a much more in depth run through of how this feature works.
Cheers,
Robert

Thanks for the information Robert, it will help my solve the problem I am having.