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 variable in condition #577

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:

steps:
    -   checkout: self
        lfs: true
        fetchDepth: 1
        condition: parameters.runTests

this syntax is supported.

But this syntax is not supported:

steps:
    -   checkout: self
        lfs: true
        fetchDepth: 1
        condition: variables.runTests

https://learn.microsoft.com/en-us/azure/devops/pipelines/process/conditions?view=azure-devops&tabs=yaml

this page mentions this as a limitation of yaml language:

For example, if you have a job that sets a variable using a runtime expression using $[ ] syntax, you can't use that variable in your custom condition.

Would it be possible to add support for runtime variable evaluation in condition ?

tapika commented 1 year ago

Correction to statement above:

condition: variables.runTests
condition: variables['runTests']

=> does not work.

condition: eq( variables['runTests'], True )
condition: eq( variables.runTests, True )

=> works correctly.

DmitriiBobreshev commented 1 year ago

Hi @tapika, thank you 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