Azure yaml pipeline "Expected mapping end"
Asked Answered
W

1

9

I want to define a deployment job (via a template) but, running my azure pipeline, the following errors is displayed:

job-deploy.yml@templates: Expected mapping end

Where is my issue ?

Following the template called:

parameters:
- name: clientBaseName
  type: string
- name: environment
  type: string
- name: aks
  type: string
- name: helm
  type: string
  default: 'helm3'
  values: 
  - 'helm2'
  - 'helm3'

jobs:
- deployment: deploy_{{ parameters.environment }}
  displayName: 'Deploy a MyPlace client.'
  environment: approvals-demo-core
  strategy:
    runOnce:
      preDeploy:
        steps:
          - template: ../tasks/task-chart-setup.yml
            parameters:
              helm: ${{ parameters.helm }}
      deploy:
        steps:
        - template: ../tasks/task-chart-deploy.yml
          parameters:
            type: data
            namespace: ${{ parameters.clientBaseName }}-{{ parameters.environment }}
            charts: ./charts/data
            values: ./output/{{ parameters.environment }}/data.yaml
            aks: {{ parameters.aks }}

        - template: ../tasks/task-chart-deploy.yml
          parameters:
            type: services
            namespace: ${{ parameters.clientBaseName }}-{{ parameters.environment }}
            charts: ./charts/services
            values: ./output/{{ parameters.environment }}/services.yaml
            aks: {{ parameters.aks }}

        - template: ../tasks/task-chart-deploy.yml
          parameters:
            type: jobs
            namespace: ${{ parameters.clientBaseName }}-{{ parameters.environment }}
            charts: ./charts/jobs
            values: ./output/{{ parameters.environment }}/jobs.yaml
            aks: {{ parameters.aks }}
Wanonah answered 16/12, 2020 at 17:33 Comment(0)
G
21

Expected mapping end usually refers to the error in the yaml syntax format. "$" is missing from the reference variable in your yaml file.

You need to change {{ parameters.environment }} to ${{ parameters.environment }}

parameters:
- name: clientBaseName
  type: string
- name: environment
  type: string
- name: aks
  type: string
- name: helm
  type: string
  default: 'helm3'
  values: 
  - 'helm2'
  - 'helm3'

jobs:
- deployment: deploy_${{ parameters.environment }}
  displayName: 'Deploy a MyPlace client.'
#  environment: approvals-demo-core
  strategy:
    runOnce:
      preDeploy:
        steps:
          - template: ../tasks/task-chart-setup.yml
            parameters:
              helm: ${{ parameters.helm }}
      deploy:
        steps:
        - template: ../tasks/task-chart-deploy.yml
          parameters:
            type: data
            namespace: ${{ parameters.clientBaseName }}-${{ parameters.environment }}
            charts: ./charts/data
            values: ./output/{{ parameters.environment }}/data.yaml
            aks: ${{ parameters.aks }}

        - template: ../tasks/task-chart-deploy.yml
          parameters:
            type: services
            namespace: ${{ parameters.clientBaseName }}-${{ parameters.environment }}
            charts: ./charts/services
            values: ./output/${{ parameters.environment }}/services.yaml
            aks: ${{ parameters.aks }}

        - template: ../tasks/task-chart-deploy.yml
          parameters:
            type: jobs
            namespace: ${{ parameters.clientBaseName }}-${{ parameters.environment }}
            charts: ./charts/jobs
            values: ./output/${{ parameters.environment }}/jobs.yaml
            aks: ${{ parameters.aks }}
Geoid answered 17/12, 2020 at 8:56 Comment(2)
thx for the feedback (as the error message is not very explicit)Wanonah
Wowzer, that error message goes to the top of the worst! Don't wanna know how long it took you to get this first time ;)Chichihaerh

© 2022 - 2024 — McMap. All rights reserved.