Pass array as inputs to Azure DevOps YAML task

you can use each function (if its available at all at this point in time):

# my-template.yml
parameters:
steps:
- ${{ each project in parameters.projects }}:
  - task: PublishBuildArtifacts@1
    displayName: Publish ${{ project }}
    inputs:
      PathtoPublish: '$(Build.ArtifactStagingDirectory)/${{ project }}.zip'
# ci.yml
steps:
- template: my-template.yml
  parameters:
    projects:
    - test1
    - test2

Github PR for this functionality: https://github.com/Microsoft/azure-pipelines-yaml/pull/2#issuecomment-452748467


For above code I got this exception running a build:

my-template.yml (Line: 1, Col: 12): Unexpected value ''

but this works for me:

# my-template.yml
parameters:
- name: projects
  type: object
  default: {}
steps:
- ${{ each project in parameters.projects }}:
  - task: PublishBuildArtifacts@1
    displayName: 'Publish ${{ project }}
    inputs:
      PathtoPublish: '$(Build.ArtifactStagingDirectory)/${{ project }}.zip'

and then:

# ci.yml
steps:
- template: my-template.yml
  parameters:
    projects:
    - test1
    - test2