3

I have a pipeline defined by the following two files. My problem is that the output of the ShowDate step is not the same in these two jobs. I would expect this because both are filled by pipeline.startTime. It seems that pipeline.startTime is evaluated in each job and the result is the start time of the job and not the pipeline itself.

So my question is: how can I get the start time of the pipeline itself? Or what am I doing wrong here?

When I run the pipeline I can see in the protocol of the job itself in section 'Job preparation parameters' that the right values are assigned to the variable DateString but this values are ignored.

azure-pipelines.yml

stages:
- stage: SomeStage    
  jobs:
  - template: job-template.yml
  - template: job-template.yml

and job-template.yml

jobs:
- job: 
  variables:
    DateString: $[format('{0:yyyy}_{0:MM}_{0:dd}_{0:HH}{0:mm}{0:ss}', pipeline.startTime)]
  pool:
    name: SomePool
  steps:
  - script: echo $(DateString)
    displayName: ShowDate
  - task: PowerShell@2
    displayName: wait
    inputs:
      targetType: 'inline'
      script: 'Start-Sleep -Seconds 10'
Rynardald
  • 329
  • 2
  • 10

0 Answers0