0
votes

How can I add send several dynamic parameters to a template with azure devops yaml?

- pwsh: |
          $affected = npm run nx affected:apps -- --base=origin/master  --head=HEAD | grep -E '( - )(\w|-|\d|_)+'
          Write-Host "##vso[task.setvariable variable=affected;]$affected"
      - template: build.yml
          parameters:
            affected: $env:AFFECTED

I think $affected is a list of string, here is the log when Write-Host "apps are ${affected}" :

enter image description here

Looks like affected: $env:AFFECTED``as parameters doesn't work. Here is the error :Mapping values are not allowed in this context`

Thanks

1

1 Answers

1
votes

Mapping values are not allowed in this context

The cause of this issue could be the YAML structure.

You could try to change the -template structure.

For example:

      - template: build.yml
        parameters:
          affected: $env:AFFECTED

The parameter and affected field need to move forward two spaces(parameters and template are aligned).

Then this pipeline may work fine.

Here is a doc about the template sample.

Hope this helps.