Random Build failure: "fatal: couldn't find remote ref refs"

We are using Self-hosted Jenkins deployment ( Kubernetes deployment ), For the past 3-4 days the deployment pipeline randomly started failing ( NO change in the pipeline ) in Declarative: Checkout SCM stage.
Pushing empty or any commit/ rebuilding pipeline sometimes worked ( not all the time )
This not only happened to the new build but also to the existing pipeline build which was passed previously

currently started working as expected, didn’t change any config/pipeline

Jenkins: 2.357
OS: Linux - 5.15.0-1045-gke
Java: 11.0.15 - Eclipse Adoptium (OpenJDK 64-Bit Server VM)


Running on jnlp-<pod-id> in /home/jenkins/agent/workspace/<path>
[Pipeline] {
[Pipeline] stage
[Pipeline] { (Declarative: Checkout SCM)
[Pipeline] checkout
The recommended git tool is: git
using credential <credentials>
Cloning the remote Git repository
Cloning with configured refspecs honoured and without tags
Cloning repository https://bitbucket.org/<workspace>/<repo>.git
ERROR: Error cloning remote repo 'origin'
hudson.plugins.git.GitException: Command "git fetch --no-tags --force --progress -- https://bitbucket.org/<workspace>/<repo>.git +refs/heads/<some-remote-branch>:refs/remotes/origin/<some-remote-branch>" returned status code 128:
stderr: fatal: couldn't find remote ref refs/heads/<some-remote-branch>

    at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.launchCommandIn(CliGitAPIImpl.java:2697)
    at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.launchCommandWithCredentials(CliGitAPIImpl.java:2111)
    at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.access$500(CliGitAPIImpl.java:87)
    at org.jenkinsci.plugins.gitclient.CliGitAPIImpl$1.execute(CliGitAPIImpl.java:623)
    at org.jenkinsci.plugins.gitclient.CliGitAPIImpl$2.execute(CliGitAPIImpl.java:852)
    at org.jenkinsci.plugins.gitclient.RemoteGitImpl$CommandInvocationHandler$GitCommandMasterToSlaveCallable.call(RemoteGitImpl.java:158)
    at org.jenkinsci.plugins.gitclient.RemoteGitImpl$CommandInvocationHandler$GitCommandMasterToSlaveCallable.call(RemoteGitImpl.java:151)
    at hudson.remoting.UserRequest.perform(UserRequest.java:211)
    at hudson.remoting.UserRequest.perform(UserRequest.java:54)
    at hudson.remoting.Request$2.run(Request.java:376)
    at hudson.remoting.InterceptingExecutorService.lambda$wrap$0(InterceptingExecutorService.java:78)
    at java.base/java.util.concurrent.FutureTask.run(Unknown Source)
    at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
    at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
    at hudson.remoting.Engine$1.lambda$newThread$0(Engine.java:122)
    at java.base/java.lang.Thread.run(Unknown Source)

Your Bitbucket server is reporting that it has a problem. That output says that command line git asked for the reference and Bitbucket either did not respond or responded that the remote reference could not be found. Check the logs on your Bitbucket server to see if it is exhausting some resource or otherwise reporting an issue.

As the git command refers to “https://bitbucket.org/”, i.e. the Bitbucket Cloud service by Atlassian, I’m not sure the server logs are available. The problem might have to be reported to Atlassian customer support.

https://bitbucket.status.atlassian.com/history doesn’t show any known incidents on the last few days; the latest one ended on April 11.