检出带有子模块的 git 存储库时出错

Mat*_*her 6 git bitbucket git-submodules jenkins

在 Jenkins 实例上部署我的测试时,我注意到一些子模块无法初始化。

在 Jenkins 中,我选中了Use credentials from default remote of parent repository可以初始化第一个子模块的复选框。不幸的是,无论我做什么,其余的都不起作用。

 > git remote # timeout=10
 > git submodule init # timeout=10
 > git submodule sync # timeout=10
 > git config --get remote.origin.url # timeout=10
 > git submodule init # timeout=10
 > git config -f .gitmodules --get-regexp ^submodule\.(.+)\.url # timeout=10
 > git config --get submodule.sub1.url # timeout=10
 > git remote # timeout=10
 > git config --get remote.origin.url # timeout=10
 > git config -f .gitmodules --get submodule.sub1.path # timeout=10
using GIT_SSH to set credentials 
 > git submodule update --init --recursive sub1
 > git config --get submodule.sub2.url # timeout=10
 > git remote # timeout=10
 > git config --get remote.origin.url # timeout=10
 > git config -f .gitmodules --get submodule.sub2.path # timeout=10
using GIT_SSH to set credentials 
 > git submodule update --init --recursive sub2
[Pipeline] }
[Pipeline] // stage
[Pipeline] }
[Pipeline] // node
[Pipeline] End of Pipeline
[Bitbucket] Notifying commit build result
[Bitbucket] Build result notified
hudson.plugins.git.GitException: Command "git submodule update --init --recursive sub2" returned status code 1:
stdout: 
stderr: Cloning into '/var/jenkins_home/workspace/develop/sub2'...
repository does not exist.
fatal: Could not read from remote repository.

Please make sure you have the correct access rights
and the repository exists.
fatal: clone of 'git@bitbucket.org:xxxx/xxx.git/sub2' into submodule path '/var/jenkins_home/workspace/develop/sub2' failed
Failed to clone 'sub2'. Retry scheduled
Cloning into '/var/jenkins_home/workspace/develop/sub2'...
repository does not exist.
fatal: Could not read from remote repository.
Run Code Online (Sandbox Code Playgroud)

我还在 中检查了这一点.git/config,我在 bitbucket 中有正确的路径到其他存储库。

Bla*_*ack 8

我遇到了同样的问题。从其物理位置删除所有子模块,然后重试:

git submodule update --init
Run Code Online (Sandbox Code Playgroud)


Mat*_*her 1

该错误与 jenkins 或 bitbucket 无关,而是 git 配置错误。.git/config未被跟踪,但.gitmodules确实被跟踪。

该路径git@bitbucket.org:xxxx/xxx.git/sub2应该让我注意到实际的错误,该错误位于.gitmodules

[submodule "sub1"]
    path = sub1
    url = git@bitbucket.org:xxxx/sub1.git
[submodule "sub2"]
    path = sub2
    url = ./sub2
Run Code Online (Sandbox Code Playgroud)

它在本地工作,因为 git 不跟踪不同的本地配置。基本上在 中.gitmodules,它应该只是地址。

git submodule add sub2我在组装存储库并在本地克隆上使用而不是完全检查它时犯了错误。