在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.
我还检查了.git/config
中是否有通往bitbucket中其他存储库的正确路径。
答案 0 :(得分:5)
我遇到了同样的问题。从其物理位置删除所有子模块,然后重试:
docker cp DEVELOP_CONTAINER:/src/ /home/aiden/src
答案 1 :(得分:0)
该错误与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
它在本地工作是因为git无法跟踪不同的本地配置。基本上在.gitmodules
中,它应该只是地址。
在组装存储库并在本地克隆上使用git submodule add sub2
而不是将其完全检出时,我犯了一个错误。