title: Provide a pipeline queue time variable with default value
body: <p>In Azure Pipelines you can <a href="https://docs.microsoft.com/azure/devops/pipelines/process/variables?view=azure-devops&amp;tabs=yaml%2Cbatch#allow-at-queue-time" rel="noreferrer">set pipeline variables at queue time</a>. You can use such a variable the same way as variables defined by the pipeline itself. </p>
  
  <p>Example:</p>
  
  <pre><code># pipeline.yml
  steps:
  - checkout: none
  - template: steps/some.yml
    parameters:
      name: $(queueTimeVar)
  
  # steps/some.yml
  parameters:
    name: 'World'
  
  steps:
    - bash: |
        echo "Hello ${{ parameters.name }}!"
  
  </code></pre>
  
  <p>But if the variable isn't set explicitly, the pipeline evaluates this expresstion to the string itself. The step template would be called with <code>name: '$(queueTimeVar)'</code> and print <code>Hello $(queueTimeVar)!</code>.</p>
  
  <p>How could I set a default value if the variable wasn't set?</p>
  
  <hr>
  
  <p>I tried adding the default value as variable but it didn't work as expected. </p>
  
  <pre><code>variables:
    queueTimeVar: MyDefault
  </code></pre>
  
  <p>Afterwards the queue time variable had no effect. The variable was always the YAML value.</p>
  
  <p>As workaround I had to add the default handling to every task which uses the value.</p>
  
  <pre><code># bash task
  value="MyDefault"
  if [ -n "$QUEUETIMEVAR" ]; then
    value="$QUEUETIMEVAR"
  fi
  </code></pre>