I am trying to assign conditional value to an environment variable in Azure DevOps but it is not working. This is my pipeline code:
pr: none
trigger: none
stages:
- stage: Mail
variables:
- group: API_Key
jobs:
- job: Sending_Email
variables:
${{ if ne( variables['RecipientEmail'], '' ) }}:
EmailId: $(RecipientEmail)
${{ if eq( variables['RecipientEmail'], '' ) }}:
EmailId: $(DefaultEmailId)
steps:
- script: echo Mail id after condition is - $(EmailId)
Here I have taken 2 environment variable "RecipientEmail" and "DefaultEmailId" and on the basis of that I want to assign value to the new variable "EmailId". But it not working. In both the cases it is picking up the "DefaultEmailId" value.
For example: DefaultEmailId: abc@example.com RecipientEmail: xyz@example.com
Ideal Output: Mail id after condition is - xyz@example.com
Current Output: Mail id after condition is - abc@example.com
Also In this I am getting a warning: "Duplicate Key" while defining the "EmailId" Variable condition.