jobs.template 定義

テンプレートで定義されているジョブのセット。

jobs:
- template: string # Required as first property. Reference to a template for this deployment.
  parameters: # Parameters used in a deployment template.

この定義を参照する定義: jobs

プロパティ

template 文字列。 最初のプロパティとして必須。
このデプロイのテンプレートへの参照。

parameters テンプレート パラメーター。
デプロイ テンプレートで使用されるパラメーター。

注釈

1 つのファイル内で一連のジョブを定義し、それを他のファイルで複数回使用できます。 ジョブ テンプレートの使用について詳しくは、テンプレートに関する記事をご覧ください。

メイン パイプラインで:

- template: string # name of template to include
  parameters: { string: any } # provided parameters

含まれているテンプレートで:

parameters: { string: any } # expected parameters
jobs: [ job ]

次の例では、1 つのジョブが 3 つのプラットフォームで繰り返されます。 そのジョブ自体は 1 回しか指定されていません。

# File: jobs/build.yml

parameters:
  name: ''
  pool: ''
  sign: false

jobs:
- job: ${{ parameters.name }}
  pool: ${{ parameters.pool }}
  steps:
  - script: npm install
  - script: npm test
  - ${{ if eq(parameters.sign, 'true') }}:
    - script: sign
# File: azure-pipelines.yml

jobs:
- template: jobs/build.yml  # Template reference
  parameters:
    name: macOS
    pool:
      vmImage: macOS-latest

- template: jobs/build.yml  # Template reference
  parameters:
    name: Linux
    pool:
      vmImage: ubuntu-latest

- template: jobs/build.yml  # Template reference
  parameters:
    name: Windows
    pool:
      vmImage: windows-latest
    sign: true  # Extra step on Windows only

こちらもご覧ください

ジョブ テンプレートの使用について詳しくは、テンプレートに関する記事をご覧ください。