While deploying my tests on a Jenkins instance, I noticed that some submodules could not be initialized.
In Jenkins, I checked the checkbox for Use credentials from default remote of parent repository
which made it possible to initialize the first submodule. Unfortunately, no matter what I do, the rest doesn't work.
> 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 '[email protected]: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.
I also checked that in .git/config
, I have the proper paths to the other repositories in bitbucket.
I faced the same issue. Delete all submodules from their physical locations and try again:
git submodule update --init
The error has nothing to do with jenkins or bitbucket but a git misconfiguration. .git/config
is not tracked, but .gitmodules
is.
The path [email protected]:xxxx/xxx.git/sub2
should have made me notice the actual error, which was in .gitmodules
:
[submodule "sub1"]
path = sub1
url = [email protected]:xxxx/sub1.git
[submodule "sub2"]
path = sub2
url = ./sub2
It worked locally because of the different local configuration that is not tracked by git. Basically in .gitmodules
, it should be only addresses.
I made the mistake when assembling the repository and using git submodule add sub2
on a local clone instead of checking it out entirely.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With