microsoft / azure-pipelines-yaml

Azure Pipelines YAML examples, templates, and community interaction
MIT License
1.19k stars 924 forks source link

Possibility to use runtime variables as a template argument #578

Closed tapika closed 1 year ago

tapika commented 1 year ago

By default yaml does permit use of compile time variables in conditions.

For example:

   -   template: mytemplate.yml
       parameters:
            param1: ${{parameters.param1}}

this syntax is supported.

But this syntax is not supported:

   -   template: mytemplate.yml
       parameters:
            param1: $(variables.param1)

According to following web page:

https://learn.microsoft.com/en-us/azure/devops/pipelines/process/runtime-parameters?view=azure-devops&tabs=script

Parameters are only available at template parsing time. Parameters are expanded just before the pipeline runs so that values surrounded by ${{ }} are replaced with parameter values. Use variables if you need your values to be more widely available during your pipeline run.

Which suggests that using runtime variables as a template parameters is not possible.

Would it be possible to add such support ?

guidooliveira commented 1 year ago

I would really love this feature, and/or possibly a way to pass arrays or objects as stringified JSON, just like we do for matrix.

DmitriiBobreshev commented 1 year ago

Hi @tapika, thank you for the suggestion and sorry for the late response, this repo is used for some questions about YAML examples and problems that you may encounter in the course of work. To request some features for more convenient use or report about the issue you can post this suggestion to the Developer Community