microsoft / azure-pipelines-yaml

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

Support for if-else runtime condition evaluation #576

Closed tapika closed 1 year ago

tapika commented 1 year ago

Currently if you want to get compile time if-else evaluation - you can do something like this:

variables:
   VERBOSE_FLAG:
   ${{if variables['System.Debug']}}:
      value: '--verbose'
   ${{else}}:
      value: ''

if you want to have runtime if-else evaluation - then it's not possible directly, but possible to make it indirectly:

https://stackoverflow.com/a/67198023/2338477

using replace function two times.

It would be nice if yaml would support directly function like:

if(<condition>, <then case> <else case>)

for runtime condition evaluation.

DmitriiBobreshev commented 1 year ago

@tapika, hello again :), thanks for the suggestion. This repo is used for some questions about YAML examples and problems that you may encounter in the course of your work. To request some features for more convenient use you can post this suggestion to the Developer Community. Sorry for the late response