我有一个管道,它有一个像这样的部分,列出了将触发该管道的管道。
resources:
# List all the microservice pipelines to be watched plus infrastructure, the pipeline name is the name
# of the stack. Note template-maven and template-gradle are not to be part of this build.
pipelines:
- pipeline: auth
project: services
source: auth
branch: master
trigger:
branches:
include:
- master
- pipeline: ai
project: services
source: artificial-intelligence
branch: master
trigger:
branches:
include:
- master
- pipeline: ui
project: frontend
source: ui CI
branch: master
trigger:
branches:
include:
- master
然后我有一个包含以下步骤的工作(因为deployment
会提取所有文件,所以我只需要每个管道中的一个文件夹
- job: publishDeploymentPipelineFiles
condition: not(canceled())
steps:
- checkout: none
- download: auth
artifact: drop
- download: ai
artifact: drop
- download: ui
artifact: drop
我所希望的是某种形式的模板,做
steps:
- checkout: none
- template: pull-deployment-manifests.yml
parameters:
sources:
- project: services
source: auth
stackName: auth
- project: services
source: artificial-intelligence
stackName: ai
- project: frontend
source: ui CI
stackName: ui
它只列出项目和CI管道,并从stackName
创建适当的管道ID,并创建资源和步骤。
我现在的解决方法是创建一个项目,该项目采用包含这些项目的CSV,并生成azure-pipelins.yml
据我所知,您不能动态创建资源。所以你创建了这个
steps:
- checkout: none
- template: pull-deployment-manifests.yml
parameters:
sources:
- project: services
source: auth
stackName: auth
- project: services
source: artificial-intelligence
stackName: ai
- project: frontend
source: ui CI
stackName: ui
并在模板内运行签出,除非您在根级别上使用这些名称定义了资源。
如文件所示:
资源在一个地方定义,可以在管道中的任何地方使用。
当然,您可以使用资源设置模板,并在YAML管道中使用此模板。您可以参考">从具有资源的模板扩展";。
但是,请注意,如果您在模板中定义了资源和步骤,则不能在YAML管道中的steps
键下使用它。您应该使用extends
键来扩展模板中的资源,就像文档中的示例一样。
您可能需要在模板中定义所有必需的步骤,或者在模板中使用其他step template
中的步骤。