Problem with Substitution variable

#1

Hello,

I’m using the Octopus variable substitution feature on a .config file in my .NET application. The problem is that I am able to use the variable in one instance of the file and it fails to function in a subsequent reference to the same variable. Is there some problem with the key name “TestModeMessage” or am I missing something?

From my log file…

16:51:31 Verbose | Octopus Deploy: Calamari version 4.3.15
16:51:31 Verbose | Environment Information:
16:51:31 Verbose | OperatingSystem: Microsoft Windows NT 6.3.9600.0
16:51:31 Verbose | OsBitVersion: x64
16:51:31 Verbose | Is64BitProcess: True
16:51:31 Verbose | CurrentUser: NT AUTHORITY\SYSTEM
16:51:31 Verbose | MachineName:
16:51:31 Verbose | ProcessorCount: 4
16:51:31 Verbose | CurrentDirectory: D:\Octopus\Work\20190508235131-41232-794
16:51:31 Verbose | TempDirectory: C:\Windows\TEMP
16:51:31 Verbose | HostProcessName: Calamari

16:51:36 Info | Performing variable substitution on ‘d:\Octopus\Applications\DEV Mobile\MobileProxy\4.4.2.26\externalWCFClient.config’
16:51:36 Info | Performing variable substitution on ‘d:\Octopus\Applications\DEV Mobile\MobileProxy\4.4.2.26\externalSettings.config’
16:51:36 Info | Performing variable substitution on ‘d:\Octopus\Applications\DEV Mobile\MobileProxy\4.4.2.26\MobileProxyLoggingConfiguration.xml’
16:51:36 Verbose | Looking for appSettings, applicationSettings, and connectionStrings in any .config files
16:51:36 Info | Updating appSettings, applicationSettings, and connectionStrings in: d:\Octopus\Applications\DEV Mobile\MobileProxy\4.4.2.26\externalSettings.config
16:51:36 Verbose | Setting ‘TestMode’ = ‘true’
16:51:36 Verbose | Setting ‘TestModeMessage’ = ‘’ *Why is it setting this to an empty string?
16:51:36 Verbose | Setting ‘ISAMUrl’ = 'https://
16:51:36 Info | No matching appSetting, applicationSetting, nor connectionString names were found in: d:\Octopus\Applications\DEV Mobile\MobileProxy\4.4.2.26\externalWCFClient.config
16:51:36 Info | No matching appSetting, applicationSetting, nor connectionString names were found in: d:\Octopus\Applications\DEV Mobile\MobileProxy\4.4.2.26\packages.config
16:51:36 Info | No matching appSetting, applicationSetting, nor connectionString names were found in: d:\Octopus\Applications\DEV Mobile\MobileProxy\4.4.2.26\Web.config

(Shannon Lewis) #3

Hi,

Thanks for getting in touch. I believe that to be getting the following line that you asked about in the log

16:51:36 Verbose | Setting ‘TestModeMessage’ = ‘’ *Why is it setting this to an empty string?

There must be a project level variable called TestModeMessage and it has a blank value in this scope. In the screenshot you provided the library variable set, could you double check the project variables and see if there is a variable with that name, if there is the Configuration variable feature will be run first and replace the text before the Subsititute in files feature executes against the file. You would need to scope variable differently, or maybe set it to V#{Octopus.Release.Number} and let it push that value into the file for you?

If that variable isn’t in the project, or another library variable set that’s being included, then could you create a variable called OctopusPrintVariables and set it to true? Could you also then run the deployment again and you should see if TestModeMessage appears in the list?

Regards
Shannon

1 Like
#4

Hi Shannon, I think I may have stumbled upon some kind of bug. I checked everywhere and could find no trace of TestModeMessage in my Library Set. I did set OctopusPrintVariables to True and observed the phantom variable “TestModeMessage” show up in the log.

I wonder if it’s an orphaned reference to an entry i may have created once before but deleted? I managed to resolve my problem by making a note of all my variables, deleting the original library set and re-adding them all one by one in a new one. After doing so, I can confirm I am no longer having this problem. Hopefully this will help anyone who may have to face this in the future but I hope you can perhaps have your developers look into it and see if they can figure out why a deleted variable might still get transformed.

Anyway, thank you for your help. I was not aware of a way to turn on debugging for the substitution variables.

(Shannon Lewis) #5

No problems, the only other thing I could think of that may have caused this would be permissions. If a variable is scoped to something you don’t have permission to, you won’t see the variable when viewing/editing the set.

It may be unlikely, given you were deploying to the same scope, but it’s the only other thing that I can think of that might explain it.

Also for completeness, there is also another variable called OctopusPrintEvaluatedVariables, that shows the variable values post substitutions being applied to them, which can be useful in some circumstances too.

Regards
Shannon

(system) closed #6

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