【问题标题】:Azure DevOps - Use YAML templates in a Git SubmoduleAzure DevOps - 在 Git 子模块中使用 YAML 模板
【发布时间】:2019-08-22 16:33:08
【问题描述】:

所以我有 1 个项目的 11 个存储库,它们都是微服务。
我有一个名为 DevOps 的存储库,其中必须跨 YAML 构建共享的所有内容都使用 Git 子模块共享。
由于某种原因,我似乎无法引用 git 模块中的 yaml 模板。

选项:


当我尝试通过触发器或手动运行构建时,出现错误:

文件 /DevOps/A/Templates/A-test-template.yml 未在 存储库 http://A.azuredevops.local/DefaultCollection/A/_git/A 分支 refs/heads/master 版本 db2884cc2d188b8e281f78e8b27e4fd74ce77d58.,意外的步骤类型: '步骤模板参考'

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

【问题讨论】:

    标签: git azure-devops yaml git-submodules azure-devops-server-2019


    【解决方案1】:

    我认为这行不通,因为必须在构建实际开始之前计算步骤,并且在构建开始后检查子模块。但是,老实说,您应该使用正确的方法(而不是子模块):

    # 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。

    https://docs.microsoft.com/en-us/azure/devops/pipelines/process/templates?view=azure-devops#using-other-repositories

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2021-10-14
      • 2020-08-10
      • 1970-01-01
      • 2020-03-01
      • 1970-01-01
      • 2020-12-03
      • 2020-03-15
      • 2021-03-12
      相关资源
      最近更新 更多