Issue
- I am able to clone public repo but facing issue with private repo using the jenkins.
- I am able to clone the private repo using the command prompt.
- I am able to clone the private repo using the tortoise git.
- But not able to clone the private repo usingthe jenkins.
Jenkins versions:
Jenkins 2.263.4
There must not be issue with the git path. I have gone through many similar questions but none of the answer is able to resolve the issue.
Wiping out workspace first.
Cloning the remote Git repository
Cloning repository https://github.com/user/module_name.git
> C:\Program Files\Git\mingw64\bin\git.exe init C:\Workspace\workspace\Walky # timeout=10
Fetching upstream changes from https://github.com/user/module_name.git
> C:\Program Files\Git\mingw64\bin\git.exe --version # timeout=10
> git --version # 'git version 2.30.1.windows.1'
using GIT_ASKPASS to set credentials Vivek git credtials for jenkins Jenkins
> C:\Program Files\Git\mingw64\bin\git.exe fetch --tags --force --progress -- https://github.com/user/module_name.git +refs/heads/*:refs/remotes/origin/* # timeout=10
ERROR: Error cloning remote repo 'origin'
hudson.plugins.git.GitException: Command "C:\Program Files\Git\mingw64\bin\git.exe fetch --tags --force --progress -- https://github.com/user/module_name.git +refs/heads/*:refs/remotes/origin/*" returned status code 128:
stdout:
stderr: remote: Repository not found.
fatal: repository 'https://github.com/user/module_name.git/' not found
at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.launchCommandIn(CliGitAPIImpl.java:2450)
at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.launchCommandWithCredentials(CliGitAPIImpl.java:2051)
at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.access$500(CliGitAPIImpl.java:84)
at org.jenkinsci.plugins.gitclient.CliGitAPIImpl$1.execute(CliGitAPIImpl.java:573)
at org.jenkinsci.plugins.gitclient.CliGitAPIImpl$2.execute(CliGitAPIImpl.java:802)
at hudson.plugins.git.GitSCM.retrieveChanges(GitSCM.java:1221)
at hudson.plugins.git.GitSCM.checkout(GitSCM.java:1299)
at hudson.scm.SCM.checkout(SCM.java:505)
at hudson.model.AbstractProject.checkout(AbstractProject.java:1206)
at hudson.model.AbstractBuild$AbstractBuildExecution.defaultCheckout(AbstractBuild.java:637)
at jenkins.scm.SCMCheckoutStrategy.checkout(SCMCheckoutStrategy.java:86)
at hudson.model.AbstractBuild$AbstractBuildExecution.run(AbstractBuild.java:509)
at hudson.model.Run.execute(Run.java:1907)
at hudson.model.FreeStyleBuild.run(FreeStyleBuild.java:43)
at hudson.model.ResourceController.execute(ResourceController.java:97)
at hudson.model.Executor.run(Executor.java:429)
ERROR: Error cloning remote repo 'origin'
Finished: FAILURE
Solution
Check first with which account Jenkins is running.
On Windows, it can run locally with a LocalSystem instead of your own account.
You can check with a Jenkins job doing a simple bat shell step:
git config --global -l --show-origin
You will see where the global Git configuration is.
If it is not running as you, Jenkins won't benefit from the same Windows Credential Manager which must have cached the remote repository hosting service credentials (username/password).
Which is why you get a 404 Not Found.
Answered By - VonC