Uploaded image for project: 'Jenkins'
  1. Jenkins
  2. JENKINS-49380

Git plugin builds although ls-remote reports no heads

    Details

    • Type: Bug
    • Status: Closed (View Workflow)
    • Priority: Major
    • Resolution: Won't Do
    • Component/s: git-plugin
    • Labels:
    • Environment:
      Jenkins 2.89.3
      git-plugin 3.7.0
      os.arch amd64
      os.name Linux
      os.version 3.10.0-693.11.6.el7.x86_64
      linux.distribution Centos 7
    • Similar Issues:

      Description

      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)

      Expected behaviour:
      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"

      Actual behaviour:
      The build will run and immediately fail, because it clones an empty repository.

      My problem relates to JENKINS-46954.
      Because ls-remote reports an empty list of heads and is somewhat not correctly reachable I get the same message from git-plugin:

      Started on Feb 1, 2018 6:22:00 PM
      Using strategy: Default
      [poll] Last Built Revision: Revision bea7fd2bc5b3930db14a4115a3ac7aff84ba2f15 (refs/remotes/origin/feature/test-123)
       > git --version # timeout=10
      using GIT_ASKPASS to set credentials 
       > git ls-remote -h https://testuser@bitbucketurl/bitbucket/scm/project/repo.git # timeout=10
      Unexpected ls-remote output line ''
      [poll] Couldn't get remote head revision
      Done. Took 0.45 sec
      Changes found
      

      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.)

        Attachments

          Activity

          Hide
          markewaite Mark Waite added a comment -

          It seems dangerous to silently ignore a report of an empty repository when the repository previously had content. I don't intend to work on this bug report.

          Show
          markewaite Mark Waite added a comment - It seems dangerous to silently ignore a report of an empty repository when the repository previously had content. I don't intend to work on this bug report.
          Hide
          ctimm Christopher Timm added a comment -

          For my personal use I have applied the suggested solution and it is working, but I understand, that including it in master introduces possible silent failures, that should not be ignored.

          I will close it as won't fix.

          Show
          ctimm Christopher Timm added a comment - For my personal use I have applied the suggested solution and it is working, but I understand, that including it in master introduces possible silent failures, that should not be ignored. I will close it as won't fix.

            People

            • Assignee:
              Unassigned
              Reporter:
              ctimm Christopher Timm
            • Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: