Use a date variable to create folder

Hello. I tried deploying package to a folder that’s created with a name having current date in it. And it fails. I tried using #{Octopus.Date.Year} and no luck. How can I overcome this?

Hi Dmitriy,

Thanks for getting in touch! Could you show me the step template/code you are using to create the folder?



Hello Dalmiro.
Thanks for the reply.
Let’s say I define a variable inside my project, and later on I used this variable as alternative directory path for deploy nuget package step.
Var defined as: (Name=testvar1; Value=C:\inetpub\wwwroot\MyTestSite\Ver#{Octopus.Date.Year}#{Octopus.Date.Month}#{Octopus.Date.Day})

In the deploy package step I used “testvar1” and all seems ok for the part C:\inetpub\wwwroot\MyTestSite\Ver, but the system variables won’t be translated, so the folder is just created using “#{Octopus.Date.Year}#{Octopus.Date.Month}#{Octopus.Date.Day}” as part of the name.

Come on! I believe the solution is simple. Anyone?

Hi Dmitriy,

The variables #{Octopus.Date.Year} , #{Octopus.Date.Month} and #{Octopus.Date.Day} are only available to be used for Version template. I’ll bring this up to the team to see if we can make them available during the deployment process.

In the meantime, you can create an Octopus variable with the date values from a Powershell step, and then use that variable for the custom install path

$date = get-date

$datestring = $date.Year.ToString() + $date.Month.ToString() + $

Set-OctopusVariable -name DateString -value $datestring

Then you can use the variable $OctopusParameters["Octopus.Action[Step Name].Output.DateString"] to create your path



Hi Dalmiro.
Thank You for the solution.