title: How can I set a variable based on which agent is running an Azure DevOps build pipeline?
body: <p>We have multiple self-hosted build agents. One step of one of our build pipelines is to copy some artifacts to a network drive. We do this via a PowerShell script, which takes the destination as a parameter. We would like this destination to vary based on which agent (or agent pool) runs the pipeline.</p>
  <p>I wondered about adding a user-defined capability to the agent that specifies this path, but you cannot then use this in the pipeline as a variable.</p>
  <p>I also tried this:</p>
  <pre><code>parameters:
  - name: PoolName
    displayName: Pool Name
    type: string
    default: Pool A
    values:
    - Pool A
    - Pool B
  
  pool:
    name: ${{ parameters.PoolName }}
  
  variables:
    ${{ if eq(parameters.PoolName, 'Pool A') }}:
        BuildArchiveLocation:  'foo'
    ${{ if eq(parameters.PoolName, 'Pool B') }}:
        BuildArchiveLocation:  'bar'
  </code></pre>
  <p>But received <code>A template expression is not allowed in this context</code> on the <code>name: ${{ parameters.PoolName }}</code> line.</p>
  <p>Is there a nice way this can be done?</p>