Skip to content

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

@puya-ms

Description

@puya-ms

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.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions