Azure DevOps多阶段管道YAML:如何签出多个存储库? [英] Azure DevOps multistage pipeline YAML: how to checkout multiple repos?

查看:156
本文介绍了Azure DevOps多阶段管道YAML:如何签出多个存储库?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的Azure DevOps管道使用来自两个不同存储库的yaml模板,其配置如下.

My Azure DevOps pipeline uses yaml templates from two different repos, which is configured as following.

  1. 有一个应用程序存储库,其中包含可部署的应用程序和一个yaml文件-管道的根"模板
  2. 模板存储库.根模板从模板存储库中调用其他模板和阶段.然后,来自此存储库的模板会调用其他模板和脚本(来自同一存储库)

模板存储库在根模板中被引用为资源.我没有找到一种方法来仅检出模板存储库一次,然后在所有管道阶段使用模板和脚本.现在,我必须在需要使用其他模板或脚本的每个阶段中手动克隆模板存储库.在每个阶段结束时,Azure Devops都会清除克隆的存储库.是否有一种简单的方法可以仅一次检查模板存储库,或者以其他方式从子阶段引用其资源?

Templates repository is referenced as a resource in the root template. I didn't find a way to checkout the templates repo just once and then use templates and scripts across all pipeline stages. For now I have to clone the templates repo manually in each stage where I need to use additional templates or scripts. At the end of each stage Azure Devops clears the cloned repo. Is there a simple way to checkout templates repo just once, or somehow else reference its resources from sub-stages?

推荐答案

我不确定,因为您没有显示YAML文件,但是您是否使用了结帐步骤:

I'm not sure since you didn't show your YAML file, but did you use checkout step:

resources:
  repositories:
    - repository: devops
      type: github
      name: kmadof/devops-templates
      endpoint: kmadof

steps:
- checkout: self
- checkout: devops
- script: |
    echo $(Build.SourcesDirectory)
    ls $(Build.SourcesDirectory) *
- template: templates/template.yaml@devops
  parameters:
    repo: devops-templates

上面的脚本检查两个存储库.在devops-templates中,我有用于主版本yaml文件(位于self存储库中)的模板.

Above script checout two repos. In devops-templates I have template which is used in main build yaml file (located in self repo).

也请看看 编辑

我对此进行了一些尝试,并尝试了一些方法.让我描述一下文件之间的第一个关系:

I work a bit with this and tried few things. Let me describe first relation between files:

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆