azure - 如何在azure devops中从我的当前存储库运行属于另一个存储库的模板(.yml)?

标签 azure azure-devops

通过以下设置,当与我的存储库对应的管道运行时,它会运行属于“anotherRepo”的模板(template.yml)文件。但是当它 checkout 时,它会 checkout 我的存储库而不是“anotherRepo”。

我的设置有问题吗?

看起来 checkout:self 没有任何影响并且不起作用

我当前的存储库:

azurepipeline.yml 文件:

variables:
  acceptanceTestsRepoName: 'anotherRepo'

resources:
  repositories:  
  - repository: 'anotherRepo'
    name: ProjectName/anotherRepo
    type: git 
    ref: master

stages:
  - stage: acceptance_tests    
    displayName: 'Run Acceptance Tests in Dev'
    jobs:       
     - template: 'azure-pipelines-templates/template.yml@${{variables.acceptanceTestsRepoName}}'

仓库:另一个仓库

模板.yml

jobs:
  - job: AcceptanceTest
    displayName: Run Acceptance Test in Dev
    pool:
      vmImage: 'ubuntu-latest'
    steps:
    - checkout: self
    - task: UsePythonVersion@0
      inputs:
        versionSpec: '$(python.version)'

最佳答案

self 始终引用与构建管道关联的存储库。在您的情况下,您需要手动 checkout anotherRepo:

# Azure Repos Git repository in the same organization
- checkout: git://anotherRepo

这假设 anotherRepo 位于同一个 Azure DevOps 组织中。如果它不是或存储在其他地方(GitHub、Bitbucket 等),您还需要将其作为资源添加到管道定义中。请参阅Check out multiple repositories in your pipeline了解详情。

关于azure - 如何在azure devops中从我的当前存储库运行属于另一个存储库的模板(.yml)?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/66069514/

相关文章:

azure - 如何在 Terraform 的状态下导入整个 Azure 资源组?

TFS 在 Visual Studio 2013 中重命名和删除文件很慢

.net - 全局禁止 NuGet 还原作为 Azure DevOps 中其他 dotnet 命令的副作用

azure - 防止 Azure 中的 Blob 出现 'Change Tier'

spring-boot - 如何使用证书将azure Ad与java Web应用程序连接?

azure - 创建 Azure 服务总线命名空间

python - 如何使用python在azure函数中使用http触发器上传html页面中的文件?

asp.net - tfignore 文件不忽略 asp.net 5 项目的文件

azure - ADO 中的产品待办事项列表

azure - 在矩阵策略构建管道中,工件发布有时会(随机)失败