Home > database >  Azure YAML if-else always fail
Azure YAML if-else always fail

Time:03-14

I am recently doing an CI/CD setup using Azure. The goal is to have the developer select the type of build to be created i.e Staging / Prod.

Thanks to enter image description here

But no matter what I select in this radio group, it always run the else block. i.e. the if-else always fails. Any help to understand what I am doing wrong here?

CodePudding user response:

Try the below, it should work. I am using the same logic to switch between different agent pools.

variables:
  ${{ if eq(parameters.selectConfiguration, 'Debug') }}: 
    config: Debug
  ${{ else }}:
    config: Release

CodePudding user response:

In YAML pipeline, you can not use the if...else expression to assign different values to a variable in different conditions.

You can only use the if expression to determine a variable which has one specified value can be available in the specified condition. See "Conditionally assign a variable".

The if...else expression can be used to:

  • Related