git - Azure DevOps - 在 Git 子模块中使用 YAML 模板
问题描述
所以我有 1 个项目的 11 个存储库,它们都是微服务。
我有一个名为 DevOps 的存储库,其中必须跨 YAML 构建共享的所有内容都使用 Git 子模块共享。
出于某种原因,我似乎无法引用 git 模块中的 yaml 模板。
选项:
当我尝试通过触发器或手动运行构建时,出现错误:
在存储库 http://A.azuredevops.local/DefaultCollection/A/_git/A 分支 refs/heads/master 版本 db2884cc2d188b8e281f78e8b27e4fd74ce77d58 中找不到文件 /DevOps/A/Templates/A-test-template.yml。,意外的步骤类型: '步骤模板参考'
YAML:
steps:
# Run Unit Tests
- template: DevOps/A/Templates/A-test-template.yml
解决方案:
使用 YAML:
resources:
repositories:
- repository: RepositoryAlias
type: git
name: "ProjectName/RepositoryName"
steps:
- template: DevOps/A/Templates/A-test-template.yml@RepositoryAlias
解决方案
我认为这行不通,因为必须在构建实际开始之前计算步骤,并且在构建开始后检查子模块。但是,老实说,您应该使用正确的方法(而不是子模块):
# Repo: Contoso/LinuxProduct
# File: azure-pipelines.yml
resources:
repositories:
- repository: templates
type: github
name: Contoso/BuildTemplates
jobs:
- template: common.yml@templates # Template reference
因此,只需将它们放在单独的 repo 中并引用 repo。
推荐阅读
- python - 将复杂的 numpy 数组转换为数量级数组的最佳方法是什么?
- angular - 如何将 Angular 数据模型类映射到 API POST 请求?
- python-3.x - 如何使用 Python 找到偏移和比例因子
- excel - 我需要在每分钟后将实时网络数据复制到新列,停留在以下代码中以移动到下一列
- arrays - 从 Swift 调用带有数组指针和 int 指针的 C 函数
- javascript - Kentico 过滤搜索中的重复项
- css - 在反应钩子中具有变量中的css属性
- javascript - 使用 NativeScript 隐藏 Android 上的导航按钮
- python - python情节线链接错误点
- python - 合并两个具有相似值但不同日期的不同数据框 pandas