Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Control Job Order in Azure DevOps Release Pipeline

I have a complicated release that spans multiple deployment groups and I am planning to use the 3rd party vsts-git-release-tag extension to tag the release. Ideally, the entire release (all jobs) would succeed first before tagging the repository.

So I am trying to work out what the best way to accomplish that is. If this were a build pipeline rather than a release pipeline, it is clear I could just arrange them using dependsOn, as follows.

jobs:
- job: Deployment_Group_1
  steps:
  - script: echo hello from Deployment Group 1
- job: Deployment_Group_2
  steps:
  - script: echo hello from Deployment Group 2
- job: Tag_Repo
  steps:
  - script: echo this is where I would tag the Repo
  dependsOn:
  - Deployment_Group_1
  - Deployment_Group_2

However, there doesn't seem to be equivalent functionality (at least currently) in release pipelines as specified in this document.

Note

Running multiple jobs in parallel is supported only in build pipelines at present. It is not yet supported in release pipelines.

Although it doesn't specifically mention the dependsOn feature, there doesn't seem to be a way to utilize it in release pipelines (correct me if I am wrong).

I realize I could probably create a separate stage containing a single job and task to create the Git tag, but that feels like a hack. Is there a better way to run a specific release job after all other release jobs have completed?

like image 856
NightOwl888 Avatar asked Dec 13 '22 12:12

NightOwl888


1 Answers

Just a suggestion: you could make use of multistage pipelines which then are also very clearly represented in the Azure Devops Ui.

Stages have jobs, jobs have steps: enter image description here

Example pipeline yml for this:

trigger:
  batch: true
  branches:
    include:
      - "*"


resources:
  containers:
    - container: ubuntu
      image: ubuntu:18.04

stages:
  - stage: STAGE1
    jobs:
     - job: PrintInfoStage1Job1
       container: ubuntu
       steps:
          - script: |
              echo "THIS IS STAGE 1, JOB 1"
            displayName: "JOB 1"
     - job: PrintInfoStage1Job2
       dependsOn: PrintInfoStage1Job1
       container: ubuntu
       steps:
          - script: |
              echo "THIS IS STAGE 1, JOB 2"
            displayName: "JOB 2"

  - stage: STAGE2
    dependsOn: STAGE1
    jobs:
      - job: PrintInfoStage2Job1
        dependsOn: []
        container: ubuntu
        steps:
          - script: |
               echo "THIS IS THE STAGE 2, JOB 1"
            displayName: "JOB 1"

      - job: PrintInfoStage2Job2
        container: ubuntu
        dependsOn: []
        steps:
          - script: |
               echo "THIS IS THE STAGE 2, JOB 2"
            displayName: "JOB 2"

Just be sure to not miss switch on this preview feature on in your user's settings.

like image 167
chris polzer Avatar answered Jan 25 '23 12:01

chris polzer