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.
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:
- assign different values to an input of the task in different conditions. See "Conditionally set a task input".
- run different steps in a job in different conditions. See "Conditionally run a step".