我们正在使用 Azure DevOps 进行构建和部署,我们正在使用 Azure DevOps 构建模板来提高构建管道的质量。我们正在使用构建管道模板,如下所示
trigger:
batch: true
branches:
include:
- "master"
stages:
- template: ../common/ci-build-python-template.yml
parameters:
PythonPath: "./"
SourcesDirForCoverage: "./"
UnitTestsDir: "./tests/"
随着我们开始使用这种方法,管理这些模板变得很困难,因为它们是个人存储库的一部分。每个 repo 所有者都有责任更新这些模板。它变得越来越难。
我想要一个公共的回购协议(很像图书馆),所有的回购协议都应该引用。因此,模板将在公共存储库中更新一次,并将反映在整个组织中。
有没有一种方法可以让所有其他回购都引用模板的公共回购?
有可能。 您可以拥有一些共享的 git 存储库,其中存储了所有模板,然后从您的 YAML 模板中引用该模板。像下面这样:
resources:
repositories:
- repository: templates
type: git
name: Contoso/Central
extends:
template: template.yml@templates
你可能想使用标签,这样你就可以更安全地推广更改并轻松恢复错误的更改。就像在这个例子中:
resources:
repositories:
- repository: templates
type: git
name: Contoso/Central
ref: refs/tags/v1.0 # optional ref to pin to
extends:
template: template.yml@templates
这里是原始出处