Currently in Azure pipelines, we can pass the list of jobs to be executed to a child template with a parameter of jobList type as shown in the doco.
Is there a way I can encapsulate these jobs from pipeline.yml that are being passed to the jobList param inside another job template and pass that template to a jobList param. I tried to structure my pipeline as follows:
pipeline.yml
deployment-template.yml
post-deploy-tests-dev.yml
post-deploy-smoke-tests-prod.yml
I would like to dynamically insert different tests' jobs to the end of the deployment template depending on the environment. I tried the jobList type parameter in the deployment-template.yml as the following but it throws an error saying mapping not expected.
#post-deploy-tests-dev.yml
jobs:
- job: Test1
steps:
- script: execute test1
#post-deploy-tests-smoke-tests-prod.yml
jobs:
- job: Test2
steps:
- script: execute test2
#pipeline.yml
...
- template: deployment-template.yml
parameters:
environment: dev
testsJobsList:
template: post-deploy-tests-dev.yml
- template: deployment-template.yml
parameters:
environment: prod
testsJobsList:
template: post-deploy-smoke-tests-prod.yml
#deployment-template.yml
parameters:
- name: testsJobsList
type: jobList
default: []
#All deployment jobs here
jobs:
...
...
#Tests as the end
- ${{ parameters.testsJobsList }}
Is there a way to dynamically pass the jobList ?
