I have a job template that is included in a pipeline a number of times. The template jobs should execute in parallel, and the final job should only execute when all template jobs have completed.
In the examples below, I have simplified both files as much as possible.
The template file:
parameters:
- name: name
type: string
jobs:
- job: test${{ parameters.name }}
displayName: 'Test ${{ parameters.name }}'
dependsOn: [] # Makes sure to run in parallel with other jobs.
steps:
- checkout: none
The template file is included in the main pipeline file:
trigger: none
jobs:
- template: templates/test.yml
parameters:
name: 'A'
- template: templates/test.yml
parameters:
name: 'B'
- job: depender
displayName: 'Depends on template jobs'
dependsOn:
testA
testB
steps:
- checkout: none
When trying to run the pipeline, I get the following error:
Job dependee depends on unknown job testA testB.
I would expect that two jobs get the names testA
and testB
after template expansion, but this does not seem to happen.
How can I make my job depend on jobs previously included using templates?
You have syntax mistake in dependsOn
. Please use this:
jobs:
- template: template-test.yml
parameters:
name: 'A'
- template: template-test.yml
parameters:
name: 'B'
- job: depender
displayName: 'Depends on template jobs'
dependsOn:
- testA
- testB
steps:
- checkout: none