Waiting for a yaml pipeline deployment job to finish

Viewed 34

I am working on having one yaml template file job dependOn a deployment job before continuing. I need my "other-template" job below to depend on the deployment job name "DeployApi"

# api-deploy.yml

jobs:  
    - deployment:  DeployApi
...
release.yml
stages: 
- stage: 'deploy_dev'
  displayName: Deploy to dev environment
  dependsOn: []
  jobs:  
    - template: api/api-deploy.yml
      parameters:
        environment: ...
        varTemplate: ...
    - template: other/other-template.yml
      parameters:
        dependsOn: ['DeployApi']

Is it possible to have the second template "other/other-template.yml" depend on the "DeployApi" deployment job? I know it's possible if it was a standard job name but I couldn't find any information on if it's possible to use dependsOn for a deployment job name.

Little bit more information: I have about 10 release templates that run parallel (I believe). I have one release template that I want to wait to run until every other template is ran.

1 Answers

Yes, you can.

release.yml

trigger:
- none

pool:
  vmImage: ubuntu-latest


stages: 
- stage: 'deploy_dev'
  displayName: Deploy to dev environment
  dependsOn: []
  jobs:  
    - template: api/api-deploy.yml
      parameters:
        environment: ...
        varTemplate: ...
    - template: other/other-template.yml
      parameters:
        dependsOn: ['DeployApi']

api/api-deploy.yml

jobs:
- job: DeployApi 
  steps: 
    - task: PowerShell@2
      inputs:
        targetType: 'inline'
        script: |
          # Write your PowerShell commands here.
          
          Write-Host "This is api-deploy.yml."

other/other-template.yml

parameters:
  dependsOn: []
jobs:
- job: getDependsOn 
  dependsOn: ${{parameters.dependsOn}}
  steps: 
    - task: PowerShell@2
      inputs:
        targetType: 'inline'
        script: |
          # Write your PowerShell commands here.
          
          Write-Host "This is other-template.yml"

Result successfully:

enter image description here

Related