Reputation: 1
Is there any way to declare environments in Yaml template?
I tried to fetch values of environemnt from pipeline to template file,but it showing error like "unexpected value 'template'".
Upvotes: 0
Views: 773
Reputation: 1122
If you are going to pass the run your pipeline and parse the environment name into the template for the deployment targeting sepcific environments. I suppose you could test with yaml below. If I misunderstand you, you could share more details.
For the template.yaml
parameters:
- name: env
type: string
default: 'dev'
stages:
- stage: deployment_${{ parameters.env }}
jobs:
- deployment: envDeployment
displayName: deploy to environment
pool:
vmImage: windows-latest
# creates the environment if it doesn't exist
environment: 'smarthotel_${{ parameters.env }}'
strategy:
runOnce:
deploy:
steps:
- script: deploy to the ${{ parameters.env }} environgment
For the main pipeline azure-pipeline.yaml
trigger: none
pool:
vmImage: windows-latest
stages:
- template: template.yml
parameters:
env: dev
- template: template.yml
parameters:
env: qa
- template: template.yml
parameters:
env: prod
Upvotes: 1