来自同一组织的管道中的多个存储库

Multiple Repostories in a Pipeline from the same organisation

我的 Azure 组织中有 2 个项目。我已经从一个存储库创建了一个管道,它的工作是将代码从当前项目中的一个存储库提升到另一个项目中的另一个存储库。我正在使用 YAML 并建立了服务连接

# Deploy to PREPROD
resources:
  repositories:
  - repository: target
    type: git
    name: 'Other Project/ThisRepo'

trigger:
  branches:
    include: [
      azure-pipelines
    ]

pool:
  name: 'My Pool'
  demands:
  - agent.computerName -equals MYPC

steps:
- checkout: self
  path: source
- checkout: target
  path: target

所以在 GUI 上,它显示了目标存储库,我可以浏览到它。但是,当我 运行 管道时,我得到以下信息:-

remote: TF401019: The Git repository with name or identifier ThisRepo does not exist or you do not have permissions for the operation you are attempting. fatal: repository 'https://dev.azure.com/myOrg/Other%20Project/_git/ThisRepo/' not found

我不明白为什么它不能访问它。我在文档中看到关于我是否可以访问它然后在创建管道时应该授予它权限...我不明白:/

TIA

请检查您的 <your project> Build Service 个帐户在组织级别是否属于 Project Collection Service Accounts

我发现类似的问题已解决 here

另一种选择是将仅对特定回购的访问权限添加到另一个项目的构建服务帐户:

要做到这一点,请前往:

  • Other Project
  • 设置
  • 回购 -> 存储库
  • select ThisRepo
  • select Security 选项卡并键入要使用此 repo 的项目名称并添加 Read 权限