对Azure DevOps上的不同存储库重复使用相同的构建管道 [英] Reuse same build pipeline for different repository on Azure DevOps
问题描述
我在Azure DevOps上有一个项目,其中包含同一个主存储库的多个派生.我为该存储库创建了一个构建管道,不幸的是,由于只能为单个存储库配置管道,因此无法在当前的fork中重复使用.
I have a project on Azure DevOps containing multiple forks of the same main repository. I created a build pipeline for that repository which unfortunately cannot be reused for the present forks since a pipeline can only be configured for a single repository.
此解决方案并不理想,因为它导致了多个相同的管道,每个分支一个管道,并且很难维护所有管道.
This solution is not ideal because leads to multiple identical pipelines, one for each fork, and maintaining all of them can be difficult.
是否有一种方法可以将一个管道用于多个存储库?
Is there a way to use one pipeline for multiple repositories?
推荐答案
您可以创建一个模板文件并从每个管道中引用该文件,这样您就可以编辑一个文件,并且每个管道都会改变.
you can create a template file and reference that file from each pipeline, that way you can edit a single file and every pipeline will change.
示例如何重用来自不同存储库的步骤文件
example how to reuse a step file from different repo
resources:
repositories:
- repository: DevOps
type: git
name: DevOps
trigger: none
jobs:
- template: vsts/yaml/build.yaml@DevOps
parameters:
solutionName: xxx
registryName: yyy
您可以查看官方文档以获取更多示例
You can take a look at the official docs for more examples
https://docs. microsoft.com/en-us/azure/devops/pipelines/process/templates?view=azure-devops
这篇关于对Azure DevOps上的不同存储库重复使用相同的构建管道的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!