3

I have two environments, preprod and prod and they are pretty much the same.

So I created an yaml file, InfurstructureTemplate.yaml

parameters:
  xxxx
  jobs:
    - job: provision_job

I want to use this template for my two environments, here is what in mind:

stages:
- stage: PreProd Environment
- template: InfurstructureTemplate.yaml
- parameters:
      xxxx

- stage: Prod Environment
- template: InfurstructureTemplate.yaml
- parameters:
      xxxx

Is this the right way to use yaml template? When I googled this, seems template is on Stages level and you can't put it on stage.

Shayki Abramczyk
  • 36,824
  • 16
  • 89
  • 114
daxu
  • 3,514
  • 5
  • 38
  • 76

2 Answers2

7

Yes, you can do it very similar, put the template in the jobs:

stages:
  - stage: PreProd_Environment
    displayName: PreProd Environment
    jobs:
      - template: InfurstructureTemplate.yaml
        parameters:
          projectDir: xxx

  - stage: Prod_Environment
    displayName: Prod Environment
    dependsOn: [ PreProd_Environment ]
    jobs:
      - template: InfurstructureTemplate.yaml
        parameters:
          projectDir: xxx
Shayki Abramczyk
  • 36,824
  • 16
  • 89
  • 114
1

You may try this too as described here

stages:
- template: InfurstructureTemplate.yaml
  parameters:
      xxxx

- template: InfurstructureTemplate.yaml
  parameters:
      xxxx
Christophe
  • 11
  • 3