You can create a loop in devops pipelines YAML by using a syntax similiar to -${{ each x in y }}:
. From my understanding, y
can be an array.
However, I find that there is no documentation for each
. The only page describing an example of it's usage is on the "Templates" page.
So my question is: how do I go about specifying an array? I know one way is to use -${{ each book in parameters.books }}:
and then pass in a "list" of books
like:
- template: template.yml
parameters:
books:
- book1
- book2
- book3
However, I'd also like to define an array as a variable:
variables:
books:
- book1
- book2
- book3
However, for this, ADO throws an error A sequence was not expected
.
Is there no way to define an array like that? I'd imagine I'd then refer to these as -${{ each book in variables.books }}:
If not, is there any other way to specify a list?