79747306

Date: 2025-08-26 20:44:29
Score: 1
Natty:
Report link

@codechurn and bryanbcook are correct, but use iif condition would be easier and shorter to use:

Reference https://learn.microsoft.com/en-us/azure/devops/pipelines/process/expressions?view=azure-devops

For given question the solution could quite simple:
azure-pipelines.yml

variables: 
   namespaceName: $[ 
     iif(notIn(variables['var-a'], '', variables['noSuch']),
         $(var-a),
         $(var-b)
     )
   ]

Note: Using variables['noSuch'] as a value Null, because Null is a special literal expression that's returned from a dictionary miss, for example. Null can be the output of an expression but can't be called directly within an expression.

Reasons:
  • Long answer (-0.5):
  • Has code block (-0.5):
  • User mentioned (1): @andare
  • Low reputation (1):
Posted by: salmira