I have a Tenant Variable in Octopus named “xxx” and a connectionString named “xxx” in the web.config of my web service named “WebService1”.
When deploying “WebService1” (defined in my Octopus project named “Project1”) I have selected the “Configuration variables” option in the Octopus deployment step, and Octopus correctly transforms the connectionString value in the deployed web.config file.
I also have another web service named “WebService2” (defined in my Octopus project named “Project1”) which ALSO has a connectionString in the web.config named “xxx”. For deploying WebService2 I need a different value in that connectionString.
I had hoped that I would be able to define a Project variable named “xxx” in Project2 and that would override the value from the Tenant variable. But it seems that the Project variable is ignored and the connectionString for BOTH deployments takes the value from the Tenant variable.
Is there a way to override the Tenant variable at Project level?
Webservice2 is deployed as a step in Project2 (not Project1)
Thanks for getting in touch! Octopus works a bit like CSS when it comes to dealing with ambiguous variables: it chooses the value with the most specific scope.
In this case a Project+Tenant-scoped variable value is more specific than a Project-scoped variable.
How have you configured your variable template for the
xxx variable? It sounds like you’ve created a “Common Variable Template” in a Library Variable Set?
My recommendation would be to define the
xxx variable (for the DB connection string) like this:
- For projects where you want each tenant to provide their own value: make a project variable template
- For projects where you want the value to be controlled by the project, and remain the same for each tenant: make it a project variable
Our guide provides a detailed example of working with tenant-specific variables which may help understand how we designed the variable template structure to work: https://octopus.com/docs/guides/multi-tenant-deployments/multi-tenant-deployment-guide/working-with-tenant-specific-variables
If I’m missing something, please send through some screenshots of your projects/variables/templates/tenants, redacting any sensitive information or making this thread private.
Hope that helps!
I am catching up on my emails, and realise that I never replied to your email, below.
So many thanks for your swift and exceptionally helpful response to my query. Your suggestion has worked exactly how I need it to.
I have been very impressed with the functionality and flexibility that Octopus offers, and your superb customer care makes it a fantastic package.
Many thanks again.
That’s great news! I’m glad it’s working well for you.