Here is error message shown
Failed to connect to a repository: Command "C:\Program Files\Git\bin\git.exe ls-remote -h https://github.com/org/project.git HEAD" returned status code 128:
stdout:
stderr: Login failed, use ctrl+c to cancel basic credential prompt.
remote: Invalid username or password.
fatal: Authentication failed for 'https://github.com/org/project.git/'
Attaching screenshot for the error shown:- enter image description here
I went through multiple platforms about the configuration issue but none of them seems to be in sync with the same. Some of them talk about git executable path that seems to be correct but don't know what actually is validated here to say git repository not found. Even after providing valid credentials as well it shows the same error.
It started showing this error message after running for 100 builds don't know what went wrong after those builds trying to configure from scratch shows the above error message. However in another machine with the same setup able to run jobs. Can someone let me know if there are any chances of the issue being with the machine as well?
Job log:-
Started by user Tom
Building in workspace C:\Program Files (x86)\Jenkins\workspace\Create
using credential "xyz"
git.exe rev-parse --is-inside-work-tree # timeout=10
Fetching changes from the remote Git repository
git.exe config remote.origin.url giturl # timeout=10
Fetching upstream changes from giturl
git.exe --version # timeout=10
using GIT_ASKPASS to set credentials xyz git
git.exe fetch --tags --force --progress giturl +refs/heads/*:refs/remotes/origin/*
ERROR: Error fetching remote repo 'origin'
hudson.plugins.git.GitException: Failed to fetch from giturl
at hudson.plugins.git.GitSCM.fetchFrom(GitSCM.java:894)
at hudson.plugins.git.GitSCM.retrieveChanges(GitSCM.java:1148)
at hudson.plugins.git.GitSCM.checkout(GitSCM.java:1179)
at hudson.scm.SCM.checkout(SCM.java:504)
at hudson.model.AbstractProject.checkout(AbstractProject.java:1208)
at hudson.model.AbstractBuild$AbstractBuildExecution.defaultCheckout(AbstractBuild.java:574)
at jenkins.scm.SCMCheckoutStrategy.checkout(SCMCheckoutStrategy.java:86)
at hudson.model.AbstractBuild$AbstractBuildExecution.run(AbstractBuild.java:499)
at hudson.model.Run.execute(Run.java:1810)
at hudson.model.FreeStyleBuild.run(FreeStyleBuild.java:43)
at hudson.model.ResourceController.execute(ResourceController.java:97)
at hudson.model.Executor.run(Executor.java:429)
Caused by: hudson.plugins.git.GitException: Command "C:\Program Files\Git\bin\git.exe fetch --tags --force --progress giturl +refs/heads/*:refs/remotes/origin/*" returned status code 128:
stdout:
stderr: remote: Not Found
fatal: repository 'giturl/' not found
at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.launchCommandIn(CliGitAPIImpl.java:2042)
at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.launchCommandWithCredentials(CliGitAPIImpl.java:1761)
at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.access$400(CliGitAPIImpl.java:72)
at org.jenkinsci.plugins.gitclient.CliGitAPIImpl$1.execute(CliGitAPIImpl.java:442)
at hudson.plugins.git.GitSCM.fetchFrom(GitSCM.java:892)
... 11 more
ERROR: Error fetching remote repo 'origin'
Finished: FAILURE
I resolved my issue in the below steps
Run this on the command line
git.exe ls-remote URL
Then provide the git credentials
After successfully doing the above steps, you will find all the heads of the repository as shown in this screenshot:
Now go to Jenkins, provide your git repository URL in SCM, and then add the credentials of your Git repo in the credentials.
Then, the above issue "Failed to connect to the repository” will be cleared.