azure-devops - 带有模板的 azure devops yaml 管道不签出引用的存储库
问题描述
我正在使用新的 Azure DevOps Yaml 多阶段管道功能
我有一个要使用模板的 Azure DevOps yaml 管道文件。我希望管道可以检出自己和另一个存储库。
出于某种原因,运行时已检出self repo,但 repo: pipelines 未检出,因此作业失败(因为它所需的某些文件依赖项不存在。
这是我的模板的摘录:
resources:
repositories:
- repository: self
- repository: pipelines
name: vstsproject/pipelines
type: git
source: pipelines
variables:
# Container registry service connection established during pipeline creation
imageRepository: 'vstsprojectweb'
dockerfilePath: '$(Build.SourcesDirectory)/src/Dockerfile.CI'
BuildConfiguration: 'Release'
tag: '$(Build.BuildId)'
stages:
- stage: 'PRD'
jobs:
- template: update-connection-string-db.yml@pipelines
parameters:
resourceGroup: 'application-DEV'
DBSearchString: '###dbservername###'
我做错了什么?
我已经参考了这个微软文档。
解决方案
您不需要在资源(即 self)中引用链接的 repo,如果它是唯一的 repo,则默认情况下会在作业(而不是部署作业)中签出,但如果您有其他 repo,那么您需要手动检查它们(使用 -checkout: <name_of_repo>)。
所以就这样做(PS:清理一下,假设回购在同一个项目中):
resources:
repositories:
- repository: pipelines
source: pipelines
variables:
# Container registry service connection established during pipeline creation
imageRepository: 'vstsprojectweb'
dockerfilePath: '$(Build.SourcesDirectory)/src/Dockerfile.CI'
BuildConfiguration: 'Release'
tag: '$(Build.BuildId)'
stages:
- stage: 'PRD'
jobs:
- checkout: self
- checkout: pipelines
- template: update-connection-string-db.yml@pipelines
parameters:
resourceGroup: 'application-DEV'
DBSearchString: '###dbservername###'
推荐阅读
- python - matplotlib 中的图例问题,我使用颜色条
- java - 如何将java对象列表传递给oracle存储过程(不能使用Spring)
- android - 我有一个结算帐户,但我无法通过 Google 路线进行路线选择。我收到消息“REQUEST_DENIED”
- python-2.7 - 可变大小的消息
- java - 有没有办法多次执行 paintComponent() 中的代码?
- excel - 嵌套 For Each 和 If Then 语句有效,但不继续下一张表
- c# - 如何在 SQL 数据库中存储和比较日期
- excel - 如何根据用户表单组合框选择查询单元格中的数据并将数据复制到用户表单文本框中
- amazon-ecs - AWS ECS - 如何从秘密管理器中检索特定密钥?
- java - 在 PCF 中运行的 Spring Boot 微服务中,Linux 二进制文件应位于何处以通过 ProcessBuilder/Runtime 调用