Error fetching remote repo 'origin'

The Jenkins server was restarted last night, the multi branch pipeline feature branch job was trying to resume the build but failed, it hung.
I terminated the job this morning, after that I cannot restart the build on the feature branch job anymore.
The master branch job is running fine.

ERROR: Error fetching remote repo ‘origin’
hudson.plugins.git.GitException: Failed to fetch from git@github.xxx.xxx/repo.git
at hudson.plugins.git.GitSCM.fetchFrom(GitSCM.java:1006)
at hudson.plugins.git.GitSCM.retrieveChanges(GitSCM.java:1248)
at hudson.plugins.git.GitSCM.checkout(GitSCM.java:1312)
at org.jenkinsci.plugins.workflow.steps.scm.SCMStep.checkout(SCMStep.java:129)
at org.jenkinsci.plugins.workflow.steps.scm.SCMStep$StepExecutionImpl.run(SCMStep.java:97)
at org.jenkinsci.plugins.workflow.steps.scm.SCMStep$StepExecutionImpl.run(SCMStep.java:84)
at org.jenkinsci.plugins.workflow.steps.SynchronousNonBlockingStepExecution.lambda$start$0(SynchronousNonBlockingStepExecution.java:47)
at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:515)
at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
at java.base/java.lang.Thread.run(Thread.java:829)
Caused by: hudson.plugins.git.GitException: Command “git fetch --no-tags --progress git@github.xxx.xxx/repo.git +refs/heads/:refs/remotes/origin/” returned status code 128:

I am able to run the git fetch cmd without any error.
I think the feature branch workspace is corrupted and I renamed it to another directory and re-created a new dir with the same name and permission.
Rerun the job and it is trying to use workspace@2 and is still failed with the same error above.

Anyone can shed some lights on this issue please?

Usually the cause of the failure is immediately after the text you included. The returned status code 128: is typically followed by text that might say something to indicate that an invalid ssh key was provided:

stderr: Permission denied (publickey).
fatal: The remote end hung up unexpectedly

It might say something to indicate that the remote branch does not exist with the message:

stderr: fatal: Couldn't find remote ref refs/heads/jenkins

It might say something to indicate that the provided key does not grant access to the repository with the message:

fatal: Could not read from remote repository.

Please make sure you have the correct access rights
and the repository exists.

It might say something to indicate that the DNS lookup of the remote hostname failed like this:

stderr: ssh: Could not resolve github.com: Name or service not known
fatal: Could not read from remote repository.
  
Please make sure you have the correct access rights
and the repository exists.

Review the text that came after that failure code 128 and that will likely hint at the problem.

Thanks Mark.
We removed the index and ran git reset on the workspace.
I don’t think the creds are causing the issue because the master branch is running fine from the multi branches pipeline.
We ran into a new error now on the feature branch: return status code 1

ERROR: Error fetching remote repo ‘origin’
hudson.plugins.git.GitException: Failed to fetch from git@github.xxx.xxx/repo.git
at hudson.plugins.git.GitSCM.fetchFrom(GitSCM.java:1006)
at hudson.plugins.git.GitSCM.retrieveChanges(GitSCM.java:1248)
at hudson.plugins.git.GitSCM.checkout(GitSCM.java:1312)
at org.jenkinsci.plugins.workflow.steps.scm.SCMStep.checkout(SCMStep.java:129)
at org.jenkinsci.plugins.workflow.steps.scm.SCMStep$StepExecutionImpl.run(SCMStep.java:97)
at org.jenkinsci.plugins.workflow.steps.scm.SCMStep$StepExecutionImpl.run(SCMStep.java:84)
at org.jenkinsci.plugins.workflow.steps.SynchronousNonBlockingStepExecution.lambda$start$0(SynchronousNonBlockingStepExecution.java:47)
at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:515)
at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
at java.base/java.lang.Thread.run(Thread.java:829)
Caused by: hudson.plugins.git.GitException: Command “git fetch --no-tags --progress git@github.xxx.xxx/repo.git +refs/heads/:refs/remotes/origin/” returned status code 1:

Hey @Lizy. As @MarkEWaite mentioned before, the error message returned from git should be immediately below the log snippet you posted. Are you able to include a few more lines below what you’ve already shared, or take a look there for what the error may be?

Hi @mtughan,

Our job is running every hour and I cannot see the build 21 hours ago from my screen to share the console error.

The problem is resolved after we added this option ‘skipDefaultCheckout’.

pipeline {
agent any
triggers {
cron(get_cron_string())
githubPush()
pollSCM(“”)
}
options {
skipDefaultCheckout(true)
parallelsAlwaysFailFast()
disableConcurrentBuilds()
buildDiscarder(logRotator(numToKeepStr: ‘20’, artifactNumToKeepStr: ‘20’))
}

After that, we removed the option and re ran the build, the job has been completed successfully.
It is strange, but everything is working fine now.

1 Like