doorman
doorman

Reputation: 16959

Time format as part of the archive zip filename

I have a build definition which includes the Archive step and I want to name the archive file using the following date format:

$(Date:yyyyMMdd).zip

However the build doesn't replace the filename with the date instead it creates a file called

$(Date

Is there a way to specify a time format for the zip file in the Archive step?

Upvotes: 0

Views: 234

Answers (1)

Shayki Abramczyk
Shayki Abramczyk

Reputation: 41655

You can't use the $(Date:yyyyMMdd) in the Archive step becuase the $(Date:yyyyMMdd) is a token for Build number format, not a variable.

You have 2 options:

  1. Like you said, put it in the build number and use the $(Build.BuildNumber).

  2. Add a PowerShell task with this script (you can use inline) before the Archive task:

    $date=$(Get-Date -Format g);
    Write-Host "##vso[task.setvariable variable=currentDate]$date"
    

    And in the Archive task use the variable $(currentDate).

Upvotes: 3

Related Questions