Dynamic variable names

Hi,

I’ve inherited an Octopus setup and been tasked to makes om changes.
Right now we have a database username per tenant for all our projects.
I’ve been tasked to split this up so we have a database username per tenant per project.
So I created some project variable templates and for now referenced the original database username variable. Now i gets tricky…maybe.
I use the database username variable in config files and they will no longer match when the variable is suddenly called project1.dbusername. So I’m thinking is i possible to set the default value for dbusername to something like…

#{#{ProjectID}.dbusername}

…which would return the value of project1.dbusername or project2.dbusername depending on which project i deployed?

This way everythin would match in the deployment process even though we started using project specifik database username variables.

Hi Thomas,

Thanks for getting in touch! It may be possible to use the nested variables like you’ve mentioned, however it would likely take quite a bit of effort if it is possible. I think a much easier solution though would be to separate out the variable names so each variable can be resolved separately. This can be done with #{ProjectID}.#{dbusername}. Would something like that accomplish what you’re after?

Let me know what you think and how you go!

Best regards,

Kenny

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