Reputation:
- job: Display_Version
displayName: Update version $(Number_Version)
steps:
....
I am trying to display a variable which is the variables of the pipeline, and it does not display it ... Can anyone explain to me why?
Upvotes: 17
Views: 22488
Reputation: 13479
To use the pipeline-level variable in the displayName
of a job or a stage, you should use the expression '${{ variables.varName }}
'. Because the displayName
of jobs and stages are set at compile time.
The expression '${{ variables.varName }}
' is called template expression which can be used to get the value of variable at compile time, before runtime starts.
The macro syntax '$(varName)
' can get the variable value during runtime before a task runs. So, you can use it in the displayName
and the input of a task.
For more details, you can see this document.
Below is an example as reference.
azure-pipelines.yml
variables:
Number_Version: 1.1.0
jobs:
- job: Display_Version
displayName: 'Job Name - Update version ${{ variables.Number_Version }}'
pool:
vmImage: ubuntu-latest
steps:
- task: Bash@3
displayName: 'Task Name - Update version $(Number_Version)'
inputs:
targetType: inline
script: echo "Input of task - Update version $(Number_Version)"
Result
Upvotes: 28