I am working on pipelines for several dotnet core projects, that all runs on a Windows Self-Hosted agent behind a firewall.
The build pipelines are ok, I wrote few pipelines in Yaml to act as release pipelines.
Each time, the first stage builds the project, the next stage release to staging and we use the environments to enforce the approval before release to preprod and approval again, before prod.
I have several projects where the solution has those projects:
I created release pipelines for each of them that all use the same template:
parameters:
stages:
- stage: Init_1
jobs:
[***]
- stage: Build_1
dependsOn: Init_1
jobs:
- job: Init
- job: Package
- job: Build
- stage: Deploy2ST_1
dependsOn: Build_1
jobs:
- deployment: MoveTo_Staging
environment: 'myApp ST'
strategy:
runOnce:
deploy:
steps:
- task: DownloadPackage@1
- task: PowerShell@2
- task: PowerShell@2
[***]
and so on for preprod and prod
The release pipeline calls the template like this :
trigger:
- none
pool:
name: '***'
stages:
- stage: InitRelease
jobs:
- job: 'InitJob'
steps: [***]
- template: myTemplate.yml@templates
parameters:
[* parameters for one project *]
This works but I was asked to create one pipeline that releases all three projects.
I tried to call the templates several times:
stages:
- stage: InitRelease
jobs:
- job: 'InitJob'
steps: [***]
- template: myTemplate.yml@templates
parameters:
[* parameters for project 1*]
- template: myTemplate.yml@templates
parameters:
[* parameters for project 2*]
- template: myTemplate.yml@templates
parameters:
[* parameters for project 3*]
The issue I have is that stages are run sequentially, it will stop running when the first one requests an approval to go to preprod
I tried to have the templates as jobs to run in parallel in one big stage:
stages:
- stage: OneStageToRunThemAll
jobs:
- template: myTemplate.yml@templates
parameters:
[* parameters for project 1*]
- template: myTemplate.yml@templates
parameters:
[* parameters for project 2*]
- template: myTemplate.yml@templates
parameters:
[* parameters for project 3*]
but I get this error : Unexpected value 'stages'
, I'm guessing that stages can be inserted inside jobs.
The output I would like to get is like this:
|
|- Init Project 1 - Init_1 - Build_1 - Deploy2ST_1 - Waiting for approval
|
|- Init Project 2 - Init_1 - Build_1 - Deploy2ST_1 - Waiting for approval
|
|- Init Project 3 - Init_1 - Build_1 - Deploy2ST_1 - Waiting for approval
Can that be done ?
Thanks
question from:
https://stackoverflow.com/questions/66065435/azure-pipelines-yaml-release-parallel-deployments