Main pipeline configuration to run additional pipelines

Viewed 53

I'm trying to setup a pipeline following the diagram which you can see below. The goal is to have a main pipeline (runner-pipeline.yml) that would run additional pipelines depending on an environment.

The runner-pipeline.yml could be split into 3 files if needed, but I want to prevent 9 pipelineX.yml files.

I know of triggers and can trigger the pipelines one after another but have no idea how to set up the environments to not to duplicate the pipelineX.yml files.

Additional note, I operate on Azure DevOps 2019 and have no chance for now to move to at least 2020.

Here's what I'm trying to do:

enter image description here

Would be grateful for any pointers, thanks.

1 Answers

There are multiple ways to do this but one would be this:

Example:

# Runner-pipeline.yml
stages:

- stage: AgentDevStage
  jobs:
  - deployment: Dev
    environment: Dev
    strategy:
      runOnce: 
        deploy:
          steps:
          - template: pipeline1.yml # Template reference
          - template: pipeline2.yml # Template reference
          - template: pipeline3.yml # Template reference

- stage: AgentTestStage
  jobs:
  - deployment: Test
    environment: Test
    strategy:
      runOnce: 
        deploy:
          steps:
          - template: pipeline1.yml # Template reference
          - template: pipeline2.yml # Template reference
          - template: pipeline3.yml # Template reference

- stage: AgentProdStage
  jobs:
  - deployment: Prod
    environment: Prod
    strategy:
      runOnce: 
        deploy:
          steps:
          - template: pipeline1.yml # Template reference
          - template: pipeline2.yml # Template reference
          - template: pipeline3.yml # Template reference

The above example presents the Runner-pipeline.yml, that has 3 stages in it which steps are defined in template yml files. Note please, that all 3 stages would run on different agents. If you would have 1 Agent in AzureDevops, they would run 1 by 1. If you would have 3 Agents, all Stages would run concurrently. Normally, what you want to do is to deploy first to the Dev environment. If everything goes well, then to the Test environment and then to the Prod environment.

If there would be an issue and failed Pipeline in Dev stage, Prod would still run and could run into the same error, producing issues on Prod. You can however control this by manual approvals or by a different pipeline logic.

This article explains the syntax about jobs.
This article explains stages.
This article explains the idea about templates.

Related