Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Get current Timestamp and concatenate with string in yml file

Setting up a yml based azure build pipeline for which publishing artifacts require timestamp based name. Trying to do something like this

'ArtifactName' + currentTimeStamp

How can this be done in an yml file?

like image 647
Arun Avatar asked Nov 18 '25 05:11

Arun


1 Answers

This should give you expected result:

trigger:
- master

pool:
  vmImage: ubuntu-latest

steps:
  - pwsh: |
      Write-Host "Setting up the date time for build variable"
      $date=$(Get-Date -format yyyyMMdd-Hmmss)
      Write-Host "##vso[task.setvariable variable=currentTimeStamp]$date"
    displayName: 'Geting timestamp'

  - task: PublishPipelineArtifact@1
    inputs:
      targetPath: '$(Pipeline.Workspace)'
      artifact: 'ArtifactName-$(currentTimeStamp)'
      publishLocation: 'pipeline'

enter image description here

like image 84
Krzysztof Madej Avatar answered Nov 20 '25 07:11

Krzysztof Madej