Issue
I following this tutorial https://www.jenkins.io/doc/tutorials/build-a-java-app-with-maven/#fork-sample-repository to create a Jenkins Pipeline.
My config for Pipeline section is
- Definition: Pipeline scrip from SCM
- SCM: git => Repository URL: I put my local path to my local repository according to the tutorial link mentioned above.
But I always get this error "Failed to connect to repository : Command "git ls-remote -h -- file:///home/aaa/Projects/doit-webservice HEAD" returned status code 128: stdout: stderr: fatal: '/home/aaa/Projects/doit-webservice' does not appear to be a git repository fatal: Could not read from remote repository. Please make sure you have the correct access rights and the repository exists."
I am sure I entered correct git credential for that repo.
My guess is, I am using Jenkins on Docker and the path to access that local folder is incorrect.
I tested another laptop which running Jenkins without Docker and it working fine.
Solution
Attach the network drive to the server, and then use docker volume
to host the network drive on the container, you can run the docker volume as the same user and group id also, so the permissions would work seamlessly, with no permissions errors when accessing the files from the host machine, or the Git server later on.
More information in the docker documentation, https://docs.docker.com/storage/volumes/
Answered By - Shaqil Ismail
Answer Checked By - Timothy Miller (JavaFixing Admin)