Variable substitution not working

I’ve defined a variable called RedisKeyPrefix with a value of #{Octopus.Release.Created | Format yyyy-MM-dd-HH-mm-ss} in my project.

I’ve turned on Substitute Variables in Files as shown below.

My config file looks like this prior to deployment:
<appSettings>
<add key=“RedisKeyPrefix” value="" />

</appSettings>

The resulting config file looks like this after deployment:
<appSettings>
<add key=“RedisKeyPrefix” value="#{Octopus.Release.Created | Format yyyy-MM-dd-HH-mm-ss}" />

</appSettings>

How do I get Octopus to take the release’s creation date, format it and put it into the config setting?

Hey Joey,

First of all, welcome to the Octopus boards!

Thanks for reaching out.

With variable substitution you need to put #{variablename} in the place where you want the variable to be.

I did a repro with the following settings and it worked for me. Take a look and see if you can adapt it on your side.

The variable name is the different, but the value is the same, I believe.



BEFORE:
image

AFTER:
image

If changing the variable syntax in your config doesnt work, can you please tell me what version of Octopus Server and Tentacle you’re running? I did the repro on 2020.2.16 and 5.0.13 respectively.

Thanks,
Jeremy

Thanks, I’ll give this a shot and see if I can get it to work in my setup.

Hey Joey,

You’re very welcome. Please let me know if it works or if we need to dig in a bit further.

Thanks,
Jeremy

I couldn’t get this to work. I have Octo Server: 2019.6.3 & Tentacle: 5.0.2

Does this feature require a newer versions?

Hi Joey,

It’s very possible something was fixed between your version and the one I reproduced it on. Is it the same results as before when you change it to #{RedisKeyPrefix}?

Thanks,
Jeremy

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