microsoft / azure-pipelines-yaml

Azure Pipelines YAML examples, templates, and community interaction
MIT License
1.19k stars 923 forks source link

Azure YAML Pipelines - Using template expression variables at non-global scope #593

Open puya-ms opened 1 year ago

puya-ms commented 1 year ago

Using the template expression variable syntax for a job-scoped variable is resulting in it being resolved to empty string. It seems that the compiler is not able to find a replacement value:

Template variables silently coalesce to empty strings when a replacement value isn't found.

Is this expected behavior? I could not find any mention of this in the documentation. Code example:

# Global variables are correctly replaced
variables:
  globalVar1: hello

extends:
  template: template.yml
    stages:
    - stage: stage1
      jobs:
      - job: job1
        variables:
          localVar1: world
        steps:
        - task: DisplayString
          inputs:
            stringToDisplay: ${{ variables.globalVar1}} ${{ variables.localVar1}}
            # This shows "hello "

Furthermore I have not been able to use the ${{ var }} syntax with variable templates either.

ivanduplenskikh commented 1 year ago

Hi @puya-ms thanks for reporting! We are working on more prioritized issues at the moment, but will get back to this one soon.