Azure Devops 管道:从模板导入变量并在同一变量块中声明变量

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

有什么方法可以在同一个 variables 块中将变量重用与模板和变量声明混合使用? 像这样:

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

经过测试,还是不行,请问各位有没有解决办法。 我知道我可以在同一个模板 vars.yml 中定义 var anotherVar,但我需要直接在此处而不是在模板中定义它。

下面的官方 Azure Devops 文档仅给出了如何从模板导入变量,但没有提供混合模板变量和直接变量的示例: https://docs.microsoft.com/en-us/azure/devops/pipelines/process/templates?view=azure-devops#variable-reuse

是的,应该可以。我也在做类似的事情。

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

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