0

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
  • Hi, any update on this issue, have you checked my answer? does it answer your question? Sep 21, 2022 at 9:50

1 Answer 1

0

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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.