huserben / TfsExtensions

Extensions for TFS 2015+ such as custom Widgets (require TFS 2017) and Build Tasks
MIT License
44 stars 22 forks source link

TriggerBuild with array parameters #226

Closed gherasim-learn closed 1 year ago

gherasim-learn commented 1 year ago

Hello!

I have a pipeline with a parameter of type object so I can define an array to loop through: image

I have a second pipeline that triggers the first pipeline. The issue is that I can't set a value for the template parameter databases: image The second pipeline fail with the following error image

huserben commented 1 year ago

Hi @gherasim-learn

I've never used objects as inputs, so this was new to me. I've recreated a similar pipeline and tried to trigger it manually, specifying a custom input from the user.

trigger: none

pool:
  vmImage: ubuntu-latest

parameters:
  - name: databases
    type: object
    displayName: Databases
    default:
      - first_database
      - second_database
      - third_database

steps:
- ${{ each database in parameters.databases }}:
  - script: echo ${{database}}
    displayName: 'Run a one-line script'

Manual Trigger

This is what is sent from Azure to the backend: Request

So I think you need a newline in the template parameter to work.

I tried to trigger it like this: templateParameters: 'databases: "- custom 1\n- Custom2"' But I got the same error as you did...

So far I'm not sure yet how this would work (if at all) - I'll keep you up to date when I find something out

gherasim-learn commented 1 year ago

Hi huserben

I tried with new line too. I also tried with and without double quotes "", and also with curly brackets {}, but without success.

UPDATE:

I tried with

templateParameters: 'databases: [custom, Custom2]'

and worked. I can't believe it. :D

It will be nice if you can add this in the documentation.

huserben commented 1 year ago

@gherasim-learn amazing, thanks for investigating and sharing here.

I've just updated the docs to include the following section: image

Thanks for contributing to the task, I really appreciate the time you took to figuring this out.

Do you see anything pending or potential improvements for the docs? If not I'd propose that we can close this issue.

gherasim-learn commented 1 year ago

Hi, sorry for the late answer.

You can close the issue, the docs looks good to me.

Thank you!