ERROR: Error fetching remote repo 'origin'

Started by user Sergio Iván Medel Ayala Running as SYSTEM Building in workspace C:\Users\sergi.jenkins\workspace\Sample_Java_Program The recommended git tool is: NONE No credentials specified > git.exe rev-parse --resolve-git-dir C:\Users\sergi.jenkins\workspace\Sample_Java_Program.git # timeout=10 Fetching changes from the remote Git repository > git.exe config remote.origin.url GitHub - sima87000/DemoJava # timeout=10 ERROR: Error fetching remote repo ‘origin’ hudson.plugins.git.GitException: Failed to fetch from GitHub - sima87000/DemoJava at hudson.plugins.git.GitSCM.fetchFrom(GitSCM.java:1003) at hudson.plugins.git.GitSCM.retrieveChanges(GitSCM.java:1245) at hudson.plugins.git.GitSCM.checkout(GitSCM.java:1309) at hudson.scm.SCM.checkout(SCM.java:540) at hudson.model.AbstractProject.checkout(AbstractProject.java:1240) at hudson.model.AbstractBuild$AbstractBuildExecution.defaultCheckout(AbstractBuild.java:649) at jenkins.scm.SCMCheckoutStrategy.checkout(SCMCheckoutStrategy.java:85) at hudson.model.AbstractBuild$AbstractBuildExecution.run(AbstractBuild.java:521) at hudson.model.Run.execute(Run.java:1900) at hudson.model.FreeStyleBuild.run(FreeStyleBuild.java:44) at hudson.model.ResourceController.execute(ResourceController.java:101) at hudson.model.Executor.run(Executor.java:442) Caused by: hudson.plugins.git.GitException: Command “git.exe config remote.origin.url GitHub - sima87000/DemoJava” returned status code 128: stdout: stderr: fatal: not in a git directory at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.launchCommandIn(CliGitAPIImpl.java:2732) at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.launchCommandIn(CliGitAPIImpl.java:2658) at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.launchCommandIn(CliGitAPIImpl.java:2654) at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.launchCommand(CliGitAPIImpl.java:1979) at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.launchCommand(CliGitAPIImpl.java:1991) at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.setRemoteUrl(CliGitAPIImpl.java:1599) at hudson.plugins.git.GitAPI.setRemoteUrl(GitAPI.java:161) at hudson.plugins.git.GitSCM.fetchFrom(GitSCM.java:991) … 11 more ERROR: Error fetching remote repo ‘origin’ Finished: FAILURE

It was working before, don´t know why is not working now

Hi there,

Command line git included in recent container images includes a fix for a security issue. Command line git now refuses to perform operations in repositories when the directory is not owned by the current user.

JENKINS-70540 includes a set of steps that show how to duplicate the issue. In that issue report, it is noted:

Command line git has decided that it is dangerous to perform git operations in a directory owned by a different user. I may consider a way to better detect it and better alert the administrator that there is a problem, but ultimately it is a mistake to perform git operations in a directory owned by a different user without intentionally configuring the safe.directory to allow it.

The preferred alternative is to fix the permissions on the directories so that they are owned by the user that is calling command line git.

A description of command line git CVE-2022-24765 is available in a GitHub blog post. The Red Hat description is also quite helpful, as is the Debian description.

Hi can you guide me how to fix this issue, I’m getting repo clone error

ERROR: Error fetching remote repo 'origin
pipeline.git" returned status code 128:
stdout: 
stderr: fatal: not in a git directory

See the posted answer immediately before your question. Read the linked articles. Either fix the incorrect directory ownerships in your system or implement the workaround that disables the command line git check for directory ownership.