如何在从另一个存储库扩展模板的管道定义中使用我的模板?

2024-03-16

我有一个从另一个存储库扩展模板的管道。该外部模板需要一个stageList called stages.

我的管道:

resources:
  repositories:
    - repository: templates
      type: git
      name: OtherProject/OtherRepo
      ref: refs/heads/main

extends:
  template: BaseTemplate.yml@templates

  stages:
  - stage: build
    jobs:
    - job: main
      steps:

我的步骤包括一些本地化,我需要执行task对于每种语言。我目前将每种语言手动定义为单独的任务:

- task: MSBuild@1
  displayName: 'Build (de-DE)'
  inputs:
    solution: '$(Build.SourcesDirectory)\MyProject.wixproj'
    msbuildArguments: '/p:Cultures="de-DE"
    ...more args, 15 lines long...

...对每种语言重复。总的。

所以我想尝试使用模板来实现这一点。但是当我将 MSBuild 任务移动到另一个文件并尝试时

- template: ./templates/localizedBuild.yml
  parameters:
    language: 'de-DE'

然后当我去排队管道运行时,ADO 给出了这个错误:

“stages”参数不是有效的 StageList。 /.pipelines/MyPipeline.yml:在存储库中找不到文件 /templates/localizedMsi.ymlhttps://company.visualstudio.com/OtherProject/_git/OtherRepo https://company.visualstudio.com/OtherProject/_git/OtherRepo

据我了解,这是因为模板的路径是相对于执行包含操作的文件来计算的...这是BaseTemplate.yml文件,不是MyPipeline.yml.

有没有办法在 yml 中表明我正在尝试引用模板my repo?


是的,如果您尚未将本地存储库定义为resources\repository它被自动声明为self

尝试添加:

- template:/templates/localizedBuild.yml@self
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

如何在从另一个存储库扩展模板的管道定义中使用我的模板? 的相关文章

随机推荐