问题描述
所以我有1个项目的11个存储库,它们都是微服务.
我有一个名为DevOps的存储库,其中必须使用Git子模块共享在YAML构建之间共享的所有内容.
由于某些原因,我似乎无法引用git模块中的yaml模板.
So i have 11 repositories of 1 project, they are all micro-services.
I have one repository called DevOps where everything that has to be shared across YAML builds, is shared using a Git Submodule.
For some reason i cant seem to reference yaml templates that are in a git module.
选项:
当我尝试通过触发器或手动运行构建时,出现错误:
When i try to run a build by trigger or manually i get the error:
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
推荐答案
我认为这行不通,因为必须在构建实际开始之前计算步骤,并在构建开始之后检出子模块.但是,老实说,您应该使用正确的方法(而不是子模块):
I think this wont work, because steps have to be calculated before build actually starts and submodules are being checked out after the build starts. But, honestly, you should just use a proper way of doing it (not submodules):
# Repo: Contoso/LinuxProduct
# File: azure-pipelines.yml
resources:
repositories:
- repository: templates
type: github
name: Contoso/BuildTemplates
jobs:
- template: common.yml@templates # Template reference
因此,只需将它们放在单独的存储库中,然后引用该存储库即可.
So just put them in a separate repo and reference the repo.
这篇关于Azure DevOps-在Git子模块中使用YAML模板的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!