Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

azure devops , displayname with variable

- 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?


1 Answers

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

    enter image description here

like image 187
Bright Ran-MSFT Avatar answered Dec 05 '25 15:12

Bright Ran-MSFT



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!