有没有一种方法可以在Azure DevOps中使用资源扩展多个模板



我有一个管道,它引用了几个具有资源的模板,我知道您可以使用extend关键字来扩展具有资源的样板。我一直在看这个文档,试图让它发挥作用。

azure-pipeline.yaml

trigger: none
resources:
repositories:
- repository: repoName
type: git
name: project/repoName
- repository: 'Release Notes'
name: 'project/Release Notes'
type: git
pipelines:
- pipeline: ooi-adf-ci
source: ooi-adf-ci
extends:
- {template: '/cicd/pipelines/templates/stages-deploy-app-registration.yaml'}
- {template: '/cicd/pipelines/templates/stages-set-app-credentials.yaml'}
- {template: '/cicd/pipelines/templates/stages-buying-release-apps.yaml'}
- {template: '/cicd/pipelines/templates/stages-buying-adf.yaml'}

我也试过类似的东西:

extends:
template:
[
'/cicd/pipelines/templates/stages-deploy-app-registration.yaml',
'/cicd/pipelines/templates/stages-set-app-credentials.yaml',
'/cicd/pipelines/templates/stages-buying-release-apps.yaml',
'/cicd/pipelines/templates/stages-buying-adf.yaml',
]

template.yaml资源消耗的位置:

...
resources:
pipelines:
- pipeline: ooi-adf-ci
source: ooi-adf-ci
...

我在我的azure-pipeline.yaml文件中得到一个错误,上面写着";一个序列是不期望的";。我想知道这是否真的可能,因为我还没有找到任何文档,或者我只是做得不正确。

我不认为您可以像您的示例那样在根级别无限扩展模板。

您可以编写一个azure-pipeline.yaml文件,其中每个作业/步骤都来自一个模板。我经常这样做,而且效果很好。

以下是官方文件:在此处输入链接描述

最新更新