Is there any possibilities to call AzDo templated with parameters?

Viewed 28

I would like to run a few templates based on the initial value chosen from the parameter and as soon as the value is chosen then a template will be issued which will further ask for more parameters only required for that template.

Let's say in main azure-pipelines.yml if a user chooses dev then simply a template will be called. However, if a user chooses test then template create-stack-tst-template.yml will be issued but along with that, it should prompt the parameters needed for this template. Is it possible?

If not, is there any possibility to club all the parameters only needed for dev and the same for test. So that when the individual templates are called then clubbed parameter will be passed which is necessary for that template to run but not for others.

Is there any kind of segregation exists?

trigger:
  - none

parameters:
  - name: DeployToEnvType
    displayName: |
        Select the env type to be deployed
    type: string
    values:
        - dev
        - test

stages:
  - ${{ if eq(parameters['DeployToEnvType'], 'dev' ) }}:
    - template: templates/create-stack-dev-template.yml
  - ${{ if ne(parameters['DeployToEnvType'], 'test' ) }}:
    - template: templates/create-stack-tst-template.yml 
      parameters:
      - name: ProjectName
        type: string
      - name: ImageSource
        type: string
1 Answers

it should prompt the parameters needed for this template. Is it possible?

This is not possible. You need to provide all parameters and pass further only those which are needed by particular template.

trigger:
  - none

parameters:
  - name: DeployToEnvType
    displayName: |
        Select the env type to be deployed
    type: string
    values:
        - dev
        - test
  - name: ImageSource
    type: string

stages:
  - ${{ if eq(parameters['DeployToEnvType'], 'dev' ) }}:
    - template: templates/create-stack-dev-template.yml
      parameters:
        ProjectName: projectA
        ImageSource: ${{ parameters.ImageSource }}
  - ${{ if ne(parameters['DeployToEnvType'], 'test' ) }}:
    - template: templates/create-stack-tst-template.yml 
      parameters:
        ProjectName: projectA
        ImageSource: ${{ parameters.ImageSource }}

If you need control at runtime you need to make corresponding runtime parameter and pass it down. If you want to have some values fixed you can just put them inline.

Related