I have 2 pipelines: Infra and Code. Both share 1 code repository.
Infra is triggered when bicep code changes and azure resources must be redeployed. Code is triggered when code changes and must be updated to function apps etc.
This is to reduce infra deployments when nothing changes, so run times get optimized.
Both pipelines have 2 stages: one for Dev env and one for Prod env. Prod env has approval that I dismiss if I just want to test code in Dev.
Now, when infra changes the function app code gets wiped away and Code pipeline should be run always after it.
But if I dismiss the approval, infra pipeline does not complete and a pipeline trigger in code won't work
# infra pipeline yaml
stages:
- stage: Dev
jobs:
- template: 'deployInfraToEnv.yaml'
parameters: ...
- stage: Prod
jobs:
- template: 'deployInfraToEnv.yaml'
parameters: ...
# code pipeline yaml
resources:
pipelines:
- pipeline: Infra
source: 'Infra pipeline'
trigger: true # run after infra pipeline completes
stages:
- stage: Dev
jobs:
- template: 'deployCodeToEnv.yaml'
parameters: ...
- stage: Prod
jobs:
- template: 'deployCodeToEnv.yaml'
parameters: ...
Is it possible to somehow setup pipelines so that
Infra pipeline dev stage completes -> Run code pipeline dev stage
Infra pipeline prod stage completes -> Run code pipeline prod stage
Or should I just give up and integrate both infra and code deployments into one pipeline.
So if I understood correctly, you have 2 scenarios:
I suggest using a separate pipeline for each scenario.
Considering you are already using templates like deployCodeToEnv.yaml
that can be easily reused across pipelines, you can keep things simple and use these templates in the first pipeline.
Something like:
# infra pipeline yaml
# When infrastructure changes deploy BOTH infra and code
stages:
- stage: DevInfra
jobs:
- template: 'deployInfraToEnv.yaml'
parameters: ...
- stage: DevCode
dependsOn: DevInfra
jobs:
- template: 'deployCodeToEnv.yaml'
parameters: ...
- stage: ProdInfra
jobs:
- template: 'deployInfraToEnv.yaml'
parameters: ...
- stage: ProdCode
dependsOn: ProdInfra
jobs:
- template: 'deployCodeToEnv.yaml'
parameters: ...
Second pipeline stays basically the same, with the exception of the trigger (removed):
# When application code changes deploy code ONLY
stages:
- stage: Dev
jobs:
- template: 'deployCodeToEnv.yaml'
parameters: ...
- stage: Prod
jobs:
- template: 'deployCodeToEnv.yaml'
parameters: ...