Issue pushing our release version into a json file

We’re using the format #{Octopus.Date.Year}.#{Octopus.Date.Month}.#{Octopus.Date.Day}-#{Octopus.Time.Hour}.#{Octopus.Time.Minute} as our release number, and our package is built using that.
We have an appsettings.json file with a ‘Version’ value that we tried replacing using

"Version":"#{Octopus.Date.Year}.#{Octopus.Date.Month}.#{Octopus.Date.Day}-#{Octopus.Time.Hour}.#{Octopus.Time.Minute}",

It’s not too surprising this didn’t work, although it was odd to see the variable string left in place, so the user saw “#{Octopus.Date.Year}.#{Octopus.Date.Month}.#{Octopus.Date.Day}-#{Octopus.Time.Hour}.#{Octopus.Time.Minute}” as the version number!
So then I tried creating a project variable ‘Version’, setting that to the result of that expression, and using the variable #{Version} in the Settings. (I’m not sure why there’s no variable builder in Settings/Release Versioning like most other places to validate input).
So now I assume I can use "Version":"#{Version}" in appsettings.json, but no, it replaces it with the value “#{Octopus.Date.Year}.#{Octopus.Date.Month}.#{Octopus.Date.Day}-#{Octopus.Time.Hour}.#{Octopus.Time.Minute}” !!
Not only that, but clicking “Create Release” suggest “Version #{Version}” as the build number, which is obviously not going to work.

How is this supposed to be done?

Ah, I see that "Version":"#{Octopus.Release.Number}" brings in the calculated release number, so that solves it for us.
It’s still not clear which values in the variables are able to be resolved. It would be great to either have a ‘test’ button of some sort on the variable expression fields to see if the expected result would apply in the given context, or at least a warning in the output when there’s a #{...} expression that fails to parse for some reason. The silent-treatment makes things tricky.

Hello,

Thanks for getting in touch. Looks like you worked out another approach. The Octopus.Date.* variables are available for use in Release Versioning under Project Settings, not anywhere else.

Thanks for bringing it to our attention, I’ve updated documentation on this so it’s clear going forward those variables cannot be used elsewhere: https://octopus.com/docs/deployment-process/releases/release-versioning

Thanks,
Nick

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