Octopus.Deployment.Created as Ticks

Hi,

is there a way to convert the #{Octopus.Deployment.Created} into Ticks instead of full date?

I want to use in from the “Variables” to update appSettings.

Thanks

Hi Per,

Thanks for getting in touch!

You can do this [DateTime]::Parse(${Octopus.Deployment.Created}).Ticks to get the ticks from the deployment created date.

Hope that helps!

Thank you and kind regards,
Henrik

Hi Henrik,

I’m afraid not, that doesn’t work from the “Variables” section of OD.

It just results in the actual output of [DateTime]::Parse(${Octopus.Deployment.Created}).Ticks in the appSetting.

Hi Per,

Sorry, I totally misread that you wanted it on the Variables tab! My apologies!

In that scenario there is no way to get the Ticks for the deployment created date.

But, what you can do is have a script step name Run a script (or anything to your liking) at the start of your deployment which does this Set-OctopusVariable -name "DeploymentStartedInTicks" -value ([DateTime]::Parse("#{Octopus.Deployment.Created}").Ticks). Then you can put this #{Octopus.Action[Run a script].Output.DeploymentStarted} (renaming the Run a script to whatever you named it) as the value of you appsetting on the variables tab and that should give you your desired result.

Hope that helps!

Thank you and kind regards,
Henrik

Thanks!

Yes, I was hoping to use something without an extra steps.
But it works though :slight_smile:

br,
Per