title: Azure YAML Get variable from a job run in a previous stage
body: <p>I am creating YAML pipeline in Azure DevOps that consists of two stages. </p>
  
  <p>The first stage (Prerequisites) is responsible for reading the git commit and creates a comma separated variable containing the list of services that has been affected by the commit.</p>
  
  <p>The second stage (Build) is responsible for building and unit testing the project. This Stage consists of many <code>templates</code>, one for each Service. In the template script, the job will check if the relevant Service in in the variable created in the previous stage. If the job finds the Service it will continue to build and test the service. However if it cannot find the service, it will skip that job. </p>
  
  <p><strong>Run.yml:</strong></p>
  
  <pre><code>stages:
  - stage: Prerequisites
    jobs:
    - job: SetBuildQueue
      steps:
      - task: powershell@2
        name: SetBuildQueue
        displayName: 'Set.Build.Queue'
        inputs:
          targetType: inline
          script: |
              ## ... PowerShell script to get changes - working as expected
              Write-Host "Build Queue Auto: $global:buildQueueVariable"
              Write-Host "##vso[task.setvariable variable=buildQueue;isOutput=true]$global:buildQueueVariable"
  
  - stage: Build
    jobs:
    - job: StageInitialization
  
    - template: Build.yml
      parameters:
        projectName: Service001
        projectLocation: src/Service001
  
    - template: Build.yml
      parameters:
        projectName: Service002
        projectLocation: src/Service002
  </code></pre>
  
  <p><strong>Build.yml:</strong></p>
  
  <pre><code>parameters:
    projectName: ''
    projectLocation: ''
  
  jobs:
  - job:
    displayName: '${{ parameters.projectName }} - Build'
    dependsOn: SetBuildQueue
    continueOnError: true
    condition: and(succeeded(), contains(dependencies.SetBuildQueue.outputs['SetBuildQueue.buildQueue'], '${{ parameters.projectName }}'))
    steps:
    - task: NuGetToolInstaller@1
      displayName: 'Install Nuget'
  </code></pre>
  
  <p><strong>Issue:</strong></p>
  
  <p>When the first stages runs it will create a variable called <code>buildQueue</code> which is populated as seen in the console output of the PowerShell script task:</p>
  
  <pre><code>Service001 Changed
  Build Queue Auto: Service001;
  </code></pre>
  
  <p>However when it gets to stage two and it tries to run the build template, when it checks the conditions it returns the following output:</p>
  
  <pre><code>Started: Today at 12:05 PM
  Duration: 16m 7s
  Evaluating: and(succeeded(), contains(dependencies['SetBuildQueue']['outputs']['SetBuildQueue.buildQueue'], 'STARS.API.Customer.Assessment'))
  Expanded: and(True, contains(Null, 'service001'))
  Result: False
  </code></pre>
  
  <p>So my question is how do I set the <code>dependsOn</code> and <code>condition</code> to get the information from the previous stage? </p>