Reputation: 3816
I am trying to build reusable pipeline and basic architecure is -
I have multiple application repositories (appRepo1, appRepo2,..) and all of them having their yaml pipeline for example (appRepo1.yml, appRepo2.yml,..)
These app pipelines will call common pipeline(common.yml) which is in different repository (CommonRepo).
The common pipeline(common.yml) will be responsible to call other template pipeline(Scanning.yml in ScanRepo,Infra.yml in InfraRepo ) which are in different repositories.
Basically I want to keep application's pipeline YAML to be very thin
. I don't want to call different templates of different repository from application pipeline. Instead Common template yaml of common repository should templates from various repository.
appRepo.yml
name: "$(BuildDefinitionName)_$(SourceBranchName)_$(date:yyyyMMdd)$(rev:.r)"
trigger: none
resources:
repositories:
- repository: CommonPipeline
type: GIT
name: CommonPipeline
ref: "dev"
extends:
template: common.yml@CommonPipeline
common.yml in CommonRepo
resources:
repositories:
- repository: InfraRepo
type: GIT
name: "InfraRepo"
ref: "dev"
- repository: ScanRepo
type: GIT
name: "ScanRepo"
ref: "dev"
variables:
- template: Pipeline/vars/app-var.yaml
stages:
- template: Pipeline/stages/scanning.yml@ScanRepo
- template: Pipeline/stages/infra.yml@InfraRepo
Is it possible to put (resources -> repositories) in both appRepo.yml and common.yml ? I am getting an error when I run appRepo1 pipeline(appRepo.yml) if i keep resources section in common.yml.
Error is -
Internal error reading the template. Expected a scalar,a sequence,or a mapping
Upvotes: 2
Views: 989
Reputation: 1649
No, it's not possible to have resources > repositories
in both root and template YAML due to the YAML schema limitations in Azure Pipelines. This would cause a duplication of the resources
section within the compiled YAML pipeline which is not valid.
So, you would need to add the repositories in the appRepo.yml
template. If you are worried about exploitation of the templates, you can check Security through templates
Also check out how you can enhance pipeline security using resources
Upvotes: 0