Set current date time in specific format to parameter

I need to initialize a parameter with the current data and time in specific format. I use powershell step with script

This one works fine:
echo "##teamcity[setParameter name='mydate' value='$([DateTime]::Now)']"

but I need to set the date in specif format, like this:
echo "##teamcity[setParameter name='conf.build.start.date' value='$([DateTime]::Now.ToString("yyyyMMdd")']"

How can I escape double quotes inside the value ?

1 comment
Comment actions Permalink

I managed to set the date in desired format like this:

$formatNow = [DateTime]::Now.ToString("yyyyMMdd-HHmmss")
Write-Host "##teamcity[setParameter name='conf.build.start.date' value='$formatNow']"

It should be executed form PowerShell step with Script source (not from file)

0

Please sign in to leave a comment.