<AnalyticsConfig xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> <Settings>
<AnalyticsSetting> <SettingName>
TrackingId</SettingName> <SettingValue>AAABBB</SettingValue> </AnalyticsSetting>
<AnalyticsSetting> <SettingName>
TrackForAdmin</SettingName> <SettingValue>true</SettingValue> </AnalyticsSetting>
</Settings> <Rules /> </AnalyticsConfig>
(Screenshot of XML:)
I need to change the SettingValue for SettingName = TrackingId. E.g. in Production environment it changes to AAACCC.
This overall scenario is different than the normal Connectionstring or AppSetting where the name for the AppSetting was unique.
In this case, there are multiple parameters named SettingValue.
How do I get to change the SettingValue for a specific SettingName ?
(i.e… I cant just set SettingName = AAABBB, as there are many variables called SettingName )
Hi,
Thanks for getting in touch! Octopus automatically does substitution on connectionStrings, appSettings and applicationSettings like you mentioned, but additional variable substitutions outside of those can be done using the substitute variables in files
feature in your package step. Here you can define your file names to perform substitution in. Check out our doc page on this feature for more info.
https://octopus.com/docs/deploying-applications/substitute-variables-in-files
Next, two project variables need to be created to hold the values for your TrackingId, scoping them accordingly to use the correct value based on the environment being deployed to. Using your example values, the steps to do this would be:
- Create two project variables with the same name (for example,
TrackingId
).
- Define the value of one as
AAABBB
, and the other AAACCC
.
- Scope the variable with value
AAACCC
to your production environment.
- In your config file, input this variable into your SettingValue section (where it will be replaced) using the syntax
#{TrackingId}
.
You can refer to our doc page covering variable substitution syntax as well.
https://octopus.com/docs/reference/variable-substitution-syntax
If you’re running this locally, keep in mind that variable substitution is done during deployment.
I hope this helps! Don’t hesitate to reach out if you have any further questions.
Kind regards,
Kenny
Thanks Kenry. Will this file pick up :
Website / Portals / 0 / GoogleAnalytics.config
It is a config file of course, but not in the root or first level. It is not updating.
Hi,
Thanks for following up! Defining the path to the config file should allow it to get picked up. I did a test with a package using the same structure. The following input in the Target files
section worked in my case (using backslashes (\
) instead of forward slashes): Website\Portals\0\GoogleAnalytics.config
. I’ve attached a screenshot of the ‘Substitute variables in files’ section of my package step. Does this value work for you?
If that doesn’t work, could you attach a copy of your verbose deployment log? That’ll give us more insight as to why it’s not working as expected. The following doc page outlines how to produce and export this log.
https://octopus.com/docs/how-to/how-to-turn-on-variable-logging-and-export-the-task-log
Feel free to mark this thread as private if you send the logs.
I look forward to hearing back!
Best regards,
Kenny
Kenneth you are brilliant. Octo is brilliant.
Thanks so much (please close this ticket)
Thanks again.
Hi,
You are very welcome! Thanks for the kind words. Don’t hesitate to reach out if you have any further questions in the future.
Best regards,
Kenny