title: Azure Devops multi-stage pipeline environment name not set properly
body: <p>I'm building a multi-stage pipeline, and I'm using a lot of templates as the deploy  jobs, tasks, and stages for each environment has a lot of shared logic. So on the stage I'm setting a <code>environmentName</code> variable, then using that in each of the jobs:</p>
  
  <pre class="lang-yaml prettyprint-override"><code>  - stage: StageReleaseProd
      displayName: Stage Release (Prod)
      variables:
        environmentName: 'prod'
      jobs:
        - deployment: DeployWebApp
          displayName: Deploy Wep App
          pool:
            vmImage: $(vmImage)
          environment: $(environmentName)
          strategy:
            runOnce:
              deploy:
                steps:
                  - template: config/pipelines/templates/_deploy.task.yml
                    parameters:
                      environmentName: $(environmentName)
  </code></pre>
  
  <p>Often times this works really well. I can see all the environments in the ADO UI and can add approval checks between stages. But I'm also frequently hitting this:</p>
  
  <p><a href="https://i.stack.imgur.com/RzU7p.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/RzU7p.png" alt="enter image description here"></a></p>
  
  <p>Sometimes the variable doesn't get interpolated. It feels like this happens 50% of the time, but I also can't deduce a pattern as to why. For now my workaround is to hardcode the environment variable without using parameters, but that severely limits how I can templatize all our pipelines.</p>