I'm trying to create a variable (group) on my YAML template, only if a certain parameter has a value. I'm using the following snippet:
variables:
- name: variableGroupName
value: app-${{parameters.environmentInitials}}
- template: /pipelines/variables/${{parameters.environmentInitials}}.yml
- group: ${{variables.variableGroupName}}
${{if parameters.parentEnvironmentInitials}}:
- group: app-${{parameters.parentEnvironmentInitials}}
Yet, when I try to trigger the pipeline I get the error:
Encountered error(s) while parsing pipeline YAML: Expected a mapping - Unexpected state while attempting to read the mapping end. State:
SequenceState:
IsStart: False
Index: 3
IsEnd: True
MappingState:
IsStart: False
Index: 3
IsKey: False
IsEnd: False
SequenceState:
IsStart: False
Index: 0
IsEnd: False
MappingState:
IsStart: False
Index: 0
IsKey: False
IsEnd: False
I've already tried several combinations since I can't find an example declaring groups with conditions without any success, any idea?
Thanks
Make sure you've got the indentation right. Also, the ${{if ...}} is a part of the list, the line should start with a hyphen:
variables:
- name: variableGroupName
value: app-${{parameters.environmentInitials}}
- template: /pipelines/variables/${{parameters.environmentInitials}}.yml
- group: ${{variables.variableGroupName}}
- ${{if parameters.parentEnvironmentInitials}}:
- group: app-${{parameters.parentEnvironmentInitials}}
Another possibility: the error might be coming from inside of the included template (- template: /pipelines/variables/${{parameters.environmentInitials}}.yml).
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