Azure 管道子模块克隆失败

问题描述 投票:0回答:3

我创建了主项目

https://dev.azure.com/GilbertHsu/pipeline_test

主项目中有 3 个项目作为子模块

https://dev.azure.com/GilbertHsu/otherProjectA

https://dev.azure.com/GilbertHsu/otherProjectB

https://dev.azure.com/GilbertHsu/otherProjectC

使用每个项目的默认设置。在管道中 azure-pipelines.yml:

jobs:
- job: MacOS
  strategy:
    matrix:
      mac:
        imageName: 'macOS-10.14'
  pool:
    vmImage: $(imageName)
  steps:
    - template: azure-pipelines-ci/macos.yml

在 azure-pipelines-ci/macos.yml 中:

# macOS-specific:
# ref. https://learn.microsoft.com/en-us/azure/devops/pipelines/yaml-schema?view=azure-devops&tabls=schema%2Cparameter-schema&tabs=schema%2Cparameter-schema#checkout
steps:
  - checkout: self
    clean: true
    path: pipeline-test 
    submodules: true

.gitmodules:

[submodule "otherProjectA"]
    path = otherProjectA
    url = ../../../otherProjectA/_git/otherProjectA
[submodule "otherProjectB"]
    path = otherProjectB
    url = ../../../otherProjectB/_git/otherProjectB
[submodule "otherProjectC"]
    path = otherProjectC
    url = ../../../otherProjectC/_git/otherProjectC

当我触发管道时,它总是失败

Submodule 'otherProjectA' (https://[email protected]/GilbertHsu/otherProjectA/_git/otherProjectA) registered for path 'otherProjectA'
Submodule 'otherProjectB' (https://[email protected]/GilbertHsu/otherProjectB/_git/otherProjectB) registered for path 'otherProjectB'
Submodule 'otherProjectC' (https://[email protected]/GilbertHsu/otherProjectC/_git/otherProjectC) registered for path 'otherProjectC'
Cloning into '/Users/runner/work/1/VMCPS/otherProjectA'...
remote: TF401019: The Git repository with name or identifier otherProjectA does not exist or you do not have permissions for the operation you are attempting.
fatal: repository 'https://dev.azure.com/GilbertHsu/otherProjectA/_git/otherProjectA/' not found
fatal: clone of 'https://[email protected]/GilbertHsu/otherProjectA/_git/otherProjectA' into submodule path '/Users/runner/work/1/VMCPS/otherProjectA' failed
Failed to clone 'otherProjectA'. Retry scheduled
Cloning into '/Users/runner/work/1/VMCPS/otherProjectB'...
remote: TF401019: The Git repository with name or identifier otherProjectB does not exist or you do not have permissions for the operation you are attempting.
fatal: repository 'https://dev.azure.com/GilbertHsu/otherProjectB/_git/otherProjectB/' not found
fatal: clone of 'https://[email protected]/GilbertHsu/otherProjectB/_git/otherProjectB' into submodule path '/Users/runner/work/1/VMCPS/otherProjectB' failed
Failed to clone 'otherProjectB'. Retry scheduled
Cloning into '/Users/runner/work/1/VMCPS/otherProjectC'...
remote: TF401019: The Git repository with name or identifier otherProjectC does not exist or you do not have permissions for the operation you are attempting.
fatal: repository 'https://dev.azure.com/GilbertHsu/otherProjectC/_git/otherProjectC/' not found
fatal: clone of 'https://[email protected]/GilbertHsu/otherProjectC/_git/otherProjectC' into submodule path '/Users/runner/work/1/VMCPS/otherProjectC' failed
Failed to clone 'otherProjectC'. Retry scheduled
Cloning into '/Users/runner/work/1/VMCPS/otherProjectA'...
remote: TF401019: The Git repository with name or identifier otherProjectA does not exist or you do not have permissions for the operation you are attempting.
fatal: repository 'https://dev.azure.com/GilbertHsu/otherProjectA/_git/otherProjectA/' not found
fatal: clone of 'https://[email protected]/GilbertHsu/otherProjectA/_git/otherProjectA' into submodule path '/Users/runner/work/1/VMCPS/otherProjectA' failed
Failed to clone 'otherProjectA' a second time, aborting

Google搜索此类错误消息,我测试了以下方法

  1. 设置每个子模块的权限:我向每个子模块的“存储库权限”的用户添加“pipeline_test Build Service”,但仍然失败。
  2. 在 url 中使用 PAT 但不起作用。

我已经被这个问题困扰好几天了,真的需要善意的帮助。

git azure-devops azure-pipelines azure-pipelines-build-task azure-pipelines-yaml
3个回答
21
投票

转到

Project Settings=>Settings
(您的管道所在的项目),禁用这两个限制:

enter image description here

像我一样禁用这两个选项,问题就解决了。


6
投票

如果您很难找到此选项,截至回答此问题时,该选项已更改为“保护对 YAML 管道中存储库的访问”。禁用此选项将允许检出子模块。 enter image description here


1
投票

将子模块存储库添加为管道资源应该可以修复错误,而无需触及项目的设置:

resources:
  repositories:
  - repository: root-repo-alias
    type: git
    name: root-repo-name
    ref: $(Build.SourceBranch)
  - repository: submodule-repo-alias
    type: git
    name: submodule-repo-name
    ref: $(Build.SourceBranch)
© www.soinside.com 2019 - 2024. All rights reserved.