Reputation: 133
I have an azure pipeline YAML file and I can't figure out how to declare a list variable in a script and use it on the next step.
What I would like is something like that:
- script: echo "##vso[task.setvariable variable=packages]@('a','b')"
- template: publish-template.yml
parameters:
packages: packages
or
- script: echo "##vso[task.setvariable variable=packages]@('a','b')"
- ${{ each package in parameters.packages }}:
- script: echo ${{ package }}
But I can't find out how it's possible.
Thanks :)
Upvotes: 5
Views: 12809
Reputation: 40909
You can't do such thing. Variables are kept as strings. So this script: echo "##vso[task.setvariable variable=packages]@('a','b')"
will produce a string ('a','b')
and not an array. You can parse is script task and treat as array but there is no way to have array served at to level as you show in your example.
Please check it here:
Yaml variables have always been string: string mappings. The doc appears to be currently correct, though we may have had a bug when last you visited.
We are preparing to release a feature in the near future to allow you to pass more complex structures. Stay tuned!
Upvotes: 2