0

Here is a piece of code:

parameters:
- name: Scenario1
  type: object
  default: ['Test1','Test2','Test3','Test4']
- name: Scenario2
  type: object
  default: ['Test5','Test6']

jobs:
- job: Test_Run
  pool:
    vmImage: 'ubuntu-latest'
  steps:
    - template: Test.yml
      parameters:
        tests: ${{ parameters['Scenario1'] }}

For now the part: tests: ${{ parameters['Scenario1'] }} is hardcoded. I would like to have something like this to be able to pick a scenario:

parameters:
- name: Scenario1
  type: object
  default: ['Test1','Test2','Test3','Test4']
- name: Scenario2
  type: object
  default: ['Test5','Test6']

jobs:
- job: Test_Run
  pool:
    vmImage: 'ubuntu-latest'
  steps:
    - template: Test.yml
      parameters:
        tests: ${{ parameters[$(Scenario)] }}

I would like to pass a $(Scenario) variable from Azure pipeline, but I do not know how to insert a variable inside ${{xxx}}. :|

1 Answers1

0

You are looking for using object types. Would be something like

- name: Scenarios
  type: object
  default:
  - ScenarioName: 'Scenario1'
    Tests: ['Test1','Test2','Test3','Test4']
  - ScenarioName: 'Scenario2'
    Tests: ['Test5','Test6']

Then it would be called like:

 - ${{ each Scenario in parameters.Scenarios}} :
        - template: test.yml
          parameters:
            ScenarioName: ${{ Scenario.ScenarioName}}
            ScenarioTests: ${{ Scenario.Tests}}
DreadedFrost
  • 2,602
  • 1
  • 11
  • 29
  • I was not precise here, sorry. I do not want to run each Scenario, I want to be able to pick one from Azure pipeline via variable $(Scenario). For now it is hardcoded, because I do not know how to put a variable inside ${{xxx}}. – Krzysztof Widera Jul 07 '21 at 10:53