We have 2 CI builds, one for the Database and one for Dotnet. These are triggered when a commit is made to the master branch for their corresponding directories, i.e. /database or /dotnet.
Off the back of the CI builds, a CD pipeline is triggered to actually deploy the new resources.
The problem I'm having is, if I merge a PR into master that has changes to both /database and /dotnet, 2 CI builds are triggered (correct) but then I also get 2 CD deployments (incorrect!). I'm trying to figure out a way that it will wait for both CI builds as they were in the same commit, and then trigger the CD pipeline.
Does anyone know if that's possible?
Below are the example files of a slimmed down code.
File structure:
├── CI-Database.yml
├── CI-Dotnet.yml
├── CD-Pipeline.yml
├── database
│ └── adatabasefile.sql
├── deploy-env.yml
└── dotnet
└── adotnetfile.cs
CI-Database.yml
trigger:
branches:
include:
- main
- releases/*
paths:
include:
- database
name: $(Build.DefinitionName)_$(Date:yyyyMMdd)$(Rev:.r)_$(SourceBranchName)
pool:
vmImage: 'ubuntu-latest'
steps:
- script: echo 'Hello from database'
- publish: '$(Build.SourcesDirectory)/database'
artifact: 'the-database'
CI-Dotnet.yml
trigger:
branches:
include:
- main
- releases/*
paths:
include:
- dotnet
name: $(Build.DefinitionName)_$(Date:yyyyMMdd)$(Rev:.r)_$(SourceBranchName)
pool:
vmImage: 'ubuntu-latest'
steps:
- script: echo 'Hello from dotnet pipeline'
- publish: '$(Build.SourcesDirectory)/dotnet'
artifact: 'the-dotnet'
CD-Pipeline.yml
trigger:
branches:
include:
- main
paths:
include:
- infrastructure
pool:
vmImage: 'ubuntu-latest'
resources:
pipelines:
- pipeline: databasepipeline
source: CI-Database
trigger:
branches:
include:
- main
- pipeline: dotnetpipeline
source: CI-Dotnet
trigger:
branches:
include:
- main
stages:
- stage: DeployDEV
displayName: 'DEV Deploy'
jobs:
- job:
steps:
- pwsh: Write-Host "Deploy the consumed CI resources here"