I have a set of working stages that look something like this.
- stage: UpdateWoW
dependsOn: Install
variables:
- group: ${{ parameters.StageVars }}
jobs:
- template: UpdateApp.yml
parameters:
AppName: WoW
Project: oxygen
- stage: UpdateSCII
dependsOn: Install
variables:
- group: ${{ parameters.StageVars }}
jobs:
- template: UpdateApp.yml
parameters:
AppName: SCII
Project: carbon
- stage: UpdateDIII
dependsOn: Install
variables:
- group: ${{ parameters.StageVars }}
jobs:
- template: UpdateApp.yml
parameters:
AppName: DIII
Project: xenon
Where I am simply calling the same template with two varying parameters. I want to clean this up with a matrix. The documented example doesn't give me much to go on when a template is involved. I have tried a few variants, but so far wherever I inject matrix or include strategy is "unexpected".
- stage: UpdateApps
dependsOn: Install
variables:
- group: ${{ parameters.StageVars }}
jobs:
- template: UpdateApp.yml
matrix:
wow:
AppName: WoW
Project: oxygen
sc2:
AppName: SCII
Project: carbon
d3:
AppName: DIII
Project: xenon
parameters:
AppName: $(AppName)
Project: $(Project)
The called template looks like this:
#UpdateApp.yml
parameters:
AppName: $(AppName)
Project: $(Project)
jobs:
- job:
timeoutInMinutes: 120
variables:
Path: D:\games
steps:
- template: prep.yml $(Path)
- script: dostuff.cmd $(Path) ${{parameters.AppName}} ${{parameters.Project}}
- script: domore.cmd $(Path) ${{parameters.AppName}} ${{parameters.Project}}
Figured it out. Matrix comes in at the job level. The stage looks like this:
- stage: UpdateApps
dependsOn: Install
variables:
- group: ${{ parameters.StageVars }}
jobs:
- template: UpdateApp.yml
The template:
#UpdateApp.yml
jobs:
- job:
timeoutInMinutes: 120
variables:
Path: D:\games
strategy:
matrix:
wow:
AppName: WoW
Project: oxygen
sc2:
AppName: SCII
Project: carbon
d3:
AppName: DIII
Project: xenon
steps:
- template: prep.yml $(Path)
- script: dostuff.cmd $(Path) $(AppName) $(Project)
- script: domore.cmd $(Path) $(AppName) $(Project)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With