microsoft/azure-pipelines-yaml

Pipeline parameters from template are not rendered in Run pipeline UI

jvmlet opened this issue ยท 6 comments

.azure-pipelines.yml
extends: 
   template: template.yml
   parameters:
     test: ${{ parameters.test }}
.template.yml
parameters:
  - name: test
    default: "false"
    type: boolean

image

This is expected, you have to define runtime parameters in the main pipeline '.azure-pipelines.yml'. I would say it's an architectural design choice, not a bug.

Thanks @matteotumiati. Any chance to get what I'm after? Like template for variables?

Depends a little bit on what you are after ๐Ÿ˜„

Let's assume you have a template repository, where you store all the templates and the project repository, where you have the "real" pipeline.

template repo
  โ”œโ”€โ”€ template-1.yml
  โ”œโ”€โ”€ template-2.yml
  โ””โ”€โ”€ variables.yml

project repo
  โ”œโ”€โ”€ ...
  โ””โ”€โ”€ azure-pipelines.yml

You could have one or more templates into the template repository, including a variables.yml file, structured in this way:

variables:
- name: variablename
  value: variableValue

In any of the templates you can refer to the variables using:

# template-1.yml
variables:
- template: variables.yml
....
steps:
...

Or you can reference the same file in the project repository:

# azure-pipelines.yml
resources:
  repositories:
    - repository: my-template-repository
      type: git
      name: project-name/my-template-repository

variables:
  - template: template-1.yml@my-template-repository

steps:
  ...

We have X repositories that use template to define the pipeline. When running manually, set of parameters should be presented and passed to templates jobs

As far as I know there's no possibility to have either variables or runtime parameters to be "available" only when running manually.
I would say you always need to provide a default value that a user can change when running the pipeline manually.

My recommendation is to go with variables.. slightly less user friendly compared to runtime parameters (but not more complicated to set when opening the build dialog), but you can override the values from REST APIs, if needed, or create templates as shown above.

With runtime parameters you cannot have templates and these must be defined on top of each pipeline, which means you will have to duplicate them X times, depending on how many repos will be using the same parameters.

Thanks @matteotumiati, I will leave the issue open, may be MS team will find this feature useful to implement