8

I created main project

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

with 3 projects as submodules in the main project

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

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

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

Which are using default settings of each project. And in the pipelines azure-pipelines.yml:

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

in the 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

the .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

when I trigger the pipelines, it always failed in

Submodule 'otherProjectA' (https://GilbertHsu@dev.azure.com/GilbertHsu/otherProjectA/_git/otherProjectA) registered for path 'otherProjectA'
Submodule 'otherProjectB' (https://GilbertHsu@dev.azure.com/GilbertHsu/otherProjectB/_git/otherProjectB) registered for path 'otherProjectB'
Submodule 'otherProjectC' (https://GilbertHsu@dev.azure.com/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://GilbertHsu@dev.azure.com/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://GilbertHsu@dev.azure.com/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://GilbertHsu@dev.azure.com/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://GilbertHsu@dev.azure.com/GilbertHsu/otherProjectA/_git/otherProjectA' into submodule path '/Users/runner/work/1/VMCPS/otherProjectA' failed
Failed to clone 'otherProjectA' a second time, aborting

Googled for such error message, I've tested for the following methods

  1. Set the permissions of each submodules: I add "pipeline_test Build Service" to Users of "Repositories Permissions" of each submodule but still got failed.
  2. Use PAT in the url but not working.

I've been stuck on this issue for several days and really need kindly helping hands.

Shayki Abramczyk
  • 36,824
  • 16
  • 89
  • 114
GilbertHsu
  • 83
  • 1
  • 4

3 Answers3

20

Go Project Settings=>Settings(The project where your pipeline exists), disable these two limitations:

enter image description here

Disable these two options like me, then the issue would be resolved.

LoLance
  • 25,666
  • 1
  • 39
  • 73
  • Thanks @Lance Li-MSFT, I check my project settings, I cannot change the setting of "Limit job authorization scope to referenced Azure DevOps repositories" – GilbertHsu Jul 29 '20 at 03:31
  • 1
    @GilbertHsu Are the options grey? If so, you need to disable those settings first in organization level! (Go organizations settings=>settings=>disable them, and then go project settings to disable them in project level) – LoLance Jul 29 '20 at 03:35
  • @GilbertHsu If you don't have permissions to do those actions, ask your admins to help you to disable them. – LoLance Jul 29 '20 at 03:36
  • @GilbertHsu If my answer works, please [accept it as answer](https://meta.stackexchange.com/a/5235/515442) so that more members with similar issue can benefit from that. Thx~ – LoLance Jul 29 '20 at 03:36
  • Thanks @Lance Li-MSFT, I've check the settings of the project where the pipeline exists, the setting "Limit job authorization scope to referenced Azure DevOps repositories" cannot be modified and seems fixed to "enabled". Both "Limit job authorization scope to current project for non-release pipelines" and "Publish metadta from pipelines (preview)" are already set to "disable". – GilbertHsu Jul 29 '20 at 03:37
  • Yes, these options grey, so just like you mentioned, I need to change it in the organization level. It did worked in the testing project! – GilbertHsu Jul 29 '20 at 03:41
5

In case you are struggling to find this option, as of the time of answering this question the option has changed to "Protect access to repositories in YAML Pipelines". Disabling this option will allow the submodule to be checked out. enter image description here

Alfred Waligo
  • 2,809
  • 3
  • 18
  • 26
1

Adding the submodule repo as a pipeline resource should fix the error without touching the project's settings:

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)
Demmostenes
  • 101
  • 1
  • 5