microsoft / azure-pipelines-yaml

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

Is it possible to use compile-time expressions/conditional insertion for demands? #549

Closed hymccord closed 2 years ago

hymccord commented 2 years ago

Just like the title asks. Is it possible to do something like this? I'm getting a couple different queue time errors (right when I press the 'Run' button). Compiles just fine. Azure DevOps 2020 for references.

This template demand:

pool:
  name: default
  ${{ if eq(parameters.runUITests, 'True') }}:
    demands:
      - InteractiveSession -equals True

produces /.pipelines/ci.yml (Line: 35, Col: 3): A template expression is not allowed in this context at queue time.

While

pool:
  name: default
  demands:
    - ${{ if eq(parameters.runUITests, 'True') }}:
      - InteractiveSession -equals True

produces: /.pipelines/ci.yml (Line: 36, Col: 7): A mapping was not expected

I can post more of the pipeline if more context is needed.
Thanks!

anatolybolshakov commented 2 years ago

Hi @InKahootz this repo is mostly for yaml templates presented in repo - I would suggest to open a ticket on developer community regarding this question. Looks like it is not allowed in this context per error message, but it could make more sense to double-check.

hymccord commented 2 years ago

@anatolybolshakov Okay! Thanks for the quick feedback. I will close this out here then.