jobs.template definition

A set of jobs defined in a template.

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

Definitions that reference this definition: jobs

Properties

template string. Required as first property.
Reference to a template for this deployment.

parameters template parameters.
Parameters used in a deployment template.

Remarks

You can define a set of jobs in one file and use it multiple times in other files. See templates for more about working with job templates.

Examples

In the main pipeline:

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

In the included template:

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

In this example, a single job is repeated on three platforms. The job itself is specified only once.

# 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

See also

See templates for more about working with job templates.