title: how can I use IF ELSE in variables of azure DevOps yaml pipeline with variable group?
body: <p>I'm trying to assign one of 2 values to a variable in addition to variable group and can't find the reference that how to use IF ELSE.</p>
  
  <p>Basically I need to convert this jerkins logic to azure DevOps.</p>
  
  <p>Jenkins</p>
  
  <pre><code>if (branch = 'master') { 
     env = 'a'
  } else if (branch = 'dev'){
      env ='b'
  }
  </code></pre>
  
  <p>I found 1 reference from the following one, but this one seems to work if the variables section doesn't have variable groups.</p>
  
  <p><a href="https://stackoverflow.com/a/57532526/5862540">https://stackoverflow.com/a/57532526/5862540</a></p>
  
  <p>But in my pipeline, I already have a variable group for secrets, so I have to use name/value convention and the example doesn't work with the errors like <code>expected a mapping</code> or <code>A mapping was not expected</code> or <code>Unexpected value 'env'</code></p>
  
  <pre><code>variables:
  - group: my-global
  - name: env
    value:
      ${{ if eq(variables['Build.SourceBranchName'], 'master') }}: 
        env: a
      ${{ if eq(variables['Build.SourceBranchName'], 'dev') }}: 
        env: b
  
  </code></pre>
  
  <p>or</p>
  
  <pre><code>variables:
  - group: my-global
  - name: env
    value:
      ${{ if eq(variables['Build.SourceBranchName'], 'master') }}: a
      ${{ if eq(variables['Build.SourceBranchName'], 'dev') }}: b
  
  </code></pre>