Output variables : Analytics config file with duplicate variable names

jxharding's Avatar

jxharding

21 Aug, 2017 08:21 AM

<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:) http://imgur.com/a/DQaNN

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 )

  1. Support Staff 1 Posted by Kenneth Bates on 22 Aug, 2017 03:26 AM

    Kenneth Bates's Avatar

    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-variable...

    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:

    1) Create two project variables with the same name (for example, TrackingId).
    2) Define the value of one as AAABBB, and the other AAACCC.
    3) Scope the variable with value AAACCC to your production environment.
    4) 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

  2. 2 Posted by jxharding on 22 Aug, 2017 01:01 PM

    jxharding's Avatar

    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.

    http://imgur.com/a/GIXEv
    http://imgur.com/a/FltuX

  3. Support Staff 3 Posted by Kenneth Bates on 23 Aug, 2017 01:24 AM

    Kenneth Bates's Avatar

    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...

    Feel free to mark this thread as private if you send the logs. :)

    I look forward to hearing back!

    Best regards,

    Kenny

  4. 4 Posted by jxharding on 23 Aug, 2017 06:03 AM

    jxharding's Avatar

    Kenneth you are brilliant. Octo is brilliant.

    Thanks so much (please close this ticket)

    Thanks again.

  5. Support Staff 5 Posted by Kenneth Bates on 23 Aug, 2017 11:55 PM

    Kenneth Bates's Avatar

    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

Reply to this discussion

Internal reply

Formatting help / Preview (switch to plain text) No formatting (switch to Markdown)

Attaching KB article:

»

Attached Files

You can attach files up to 10MB

If you don't have an account yet, we need to confirm you're human and not a machine trying to post spam.

Keyboard shortcuts

Generic

? Show this help
ESC Blurs the current field

Comment Form

r Focus the comment reply box
^ + ↩ Submit the comment

You can use Command ⌘ instead of Control ^ on Mac