How can i set a Azure DevOps Pipeline Varible which contains the date in this Format: 25.07.2020

Viewed 8644

im not using yaml, because my companie uses TFVC, so i need the classic way.

With $[pipeline.startTime] i get the starttime, but now i need it formated in this way: dd.MM.yyyy

a powershellscript like in VSO(TFS) - get current date time as variable helped me, but set the day directly in the variables would be a cleaner way

2 Answers

How can i set a Azure DevOps Pipeline Varible which contains the date in this Format: 25.07.2020

Since you are using the classic way, nested variables are not supported in the build pipeline. So, we could not use the variables like $(Get-Date -Format Date:MMddyy) to set the date time.

We could only set the variable like:

$[format('{0:ddMMyyyy}', pipeline.startTime)]

In this way, we could get the value 10072020, not the 10.07.2020 without .. And I could not add any interval between ddMMyyyy, it does not supported by Azure pipeline.

Besides, as workaround, we could defined the Build number format in the Options tab with value $(DayOfMonth).$(Month).$(Year:yyyy):

enter image description here

Then we could use variable $(Build.BuildNumber) directly to get the date time:

enter image description here

Hope this helps.

Related