Azure Devops pipeline: import variables from template and declare variables in the same variables block

Viewed 729

Is there any way that we can mix the variable reuse with template and variable declaration in the same variables block ? Something like this:

variables:
  - template: vars.yml  # Template reference
  anotherVar: http://$(oneVarFromVarsYml)/xxx

After the test, it doesn't work, I would like to know if you have a workaround. I know I can define the var anotherVar in the same template vars.yml, but I have the needs to define it directly here not in the template.

The below official Azure Devops docs gives only how to import vars from a template, but it doesn't provide an example for case we have mixed template vars and direct vars: https://docs.microsoft.com/en-us/azure/devops/pipelines/process/templates?view=azure-devops#variable-reuse

1 Answers

Yes, should work. I'm doing something like that as well.

variables:
- template: config/configuration.yaml  # contains (amongst others) a var "bar"

- name: 'testVar'
  value: 'foo-$(bar)'
Related