title: Conditional dependent job in Azure Devops YAML pipelines
body: <p>I'm building a complex pipeline in yaml and I'm trying to create a dependency between two jobs such that the latter job runs after the former, but only if the former is set to run based on a parameter. I can't seem to wrap my head around whether this is doable or not.</p>
  
  <p>I have a pipeline defined like this:</p>
  
  <pre><code>parameters:
  - name: doJobA
    type: boolean
  
  stages:
    jobs:
    - job: JobA
      condition: eq('${{ parameters.doJobA }}', true)
      # ... details removed for brevity
  
    - job: JobB
      dependsOn: JobA
      # ... details removed for brevity
  </code></pre>
  
  <p><code>JobB</code> should run after <code>JobA</code> if <code>parameters.doJobA</code> is true, or immediately if <code>parameters.doJobA</code> is false. Simply adding the <code>dependsOn</code> condition causes <code>JobB</code> to be skipped if the <code>JobA</code> condition is not met which makes sense, but I'd like it to run regardless.</p>
  
  <p>Is it possible to define a conditional <code>dependsOn</code> in this manner?</p>
  
  <p>EDIT: I've run into an additional problem with this that renders the solution below unusable. I need the condition to depend upon a variable set by an earlier running PowerShell script and not based on parameters.</p>