Substitute variables in files feature - all directories?

Does the feature “Substitute variables in files” only search the root directory or the SearchOption.AllDirectories? It appears it is only doing the root directory and misses config files further up the chain.

I have a package that contains a 7zip file which is extracted in a pre-deploy custom powershell script after the nuget package is extracted. From the documentation, the variable replacement does not happen until after any custom pre-deploy ps scripts are run. However, it is unable to find any config files – so either a) it is not recursively looking for config files or b) it is firing before the 7zip file is extracted.

Hi Joshua,

You’re correct - the file paths are fixed relative to the root of the package.

If the location of the extracted zip is dynamic, you can use:

Set-OctopusVariable -Name "ZipLocation" -Value $extractedPath

…to make the location bindable by the substitution step (i.e. use #{ZipLocation}\Foo.config as the target file).

Hope this helps,
Nick

I really need it to apply to all config files, not just one. I have a package that has multiple configs in different folders. How can I apply the variable replacement for this case?

Via Mobile

Hi Josh,

It’s possible to specify more than one file using newline separators:

#{ZipLocation}\Foo.config
#{ZipLocation}\Another\Bar.config

By the sounds of it though you’re after wildcard/globbing in the paths, which we don’t support right now. I’m working on a step template that will provide this in a future version; for now writing PowerShell is your best option.

Regards,
Nick

Is it possible to have a wildcard looking for all the files of a given extension?

Hi Byron,

Thankgs for getting in touch. Wildcards can be used for file names, but not for paths

This would work
{ZipLocation}\Configs*.config

This would not work
{ZipLocation}\*\*.config

Hope that helps!

Dalmiro

Thanks Dalmiro!

I found that importing this step script in Octopus was more flexible

https://library.octopusdeploy.com/#!/step-template/actiontemplate-variables-substitute-in-files

it allows me to do recursiveness and wildcards.

Byron