I have a git server (Bitbucket server), that for unknown reasons reports an empty list of heads to ls-remote (and if cloned that moment also results in an empty cloned repository).
Sadly the server is not under my control, so the debug capabilites I have on the bitbucket server are very restricted. the root of the problem in my case is on bitbucket, but the resulting behaviour on jenkins doesn't seem correct to me either.
Steps to reproduce:
1. Create a job with git scm source
2. Run it successfully (optional, but proves that the general jenkins-git-config is correct)
3. Configure the server to respond with (i suspect) HTTP 200 but return an empty list of heads (some server config appears to make the server believe the repository is empty)
The build will not run, because the list of heads is empty. So the repository is either really empty and there is "nothing to build" or it is currently not working correctly, which also results in a "empty repository" or better "nothing to build"
The build will run and immediately fail, because it clones an empty repository.
My problem relates to
Because ls-remote reports an empty list of heads and is somewhat not correctly reachable I get the same message from git-plugin:
My problem is, that the project is set to poll (again due to the fact, that I don't have access to the server configuration), so it will poll every 5 minutes. If the server has the described problem the poll will return the above "error" and start a build for all my jobs that poll. Which will then fail, because at that moment the server is offering an empty repository to clone.
What would probably fix my issue is, if https://github.com/jenkinsci/git-plugin/blob/b3e384d2ecd130867f34d047c1f5903d4ea78fec/src/main/java/hudson/plugins/git/GitSCM.java#L676 did return a NO_CHANGES instead of a BUILD_NOW (because according to ls-remote we already know there is nothing to build).
I currently don't have a workaround (have thought about setting up a "git proxy", that will work more reliably, but I would reallly like to save the resources to implement this hack.)