variables.template 定義

您可以在一個檔案中定義一組變數,並將其多次用於其他檔案。

variables:
- template: string # Required as first property. Template file with variables.
  parameters: # Parameters to map into the template.

參考此定義的定義: 變數

屬性

template 字串。 做為第一個屬性的必要專案。
具有變數的範本檔案。

parameters 範本參數。
要對應至範本的參數。

範例

在此範例中,有一組變數會在多個管線中重複進行。 這些變數只會指定一次。

# File: variables/build.yml
variables:
- name: vmImage
  value: vs2017-win2016
- name: arch
  value: x64
- name: config
  value: debug
# File: component-x-pipeline.yml
variables:
- template: variables/build.yml  # Template reference
pool:
  vmImage: ${{ variables.vmImage }}
steps:
- script: build x ${{ variables.arch }} ${{ variables.config }}
# File: component-y-pipeline.yml
variables:
- template: variables/build.yml  # Template reference
pool:
  vmImage: ${{ variables.vmImage }}
steps:
- script: build y ${{ variables.arch }} ${{ variables.config }}

另請參閱