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

FATAL: Could not checkout null with start point after a reset --hard to remove a commit

    • Icon: Bug Bug
    • Resolution: Unresolved
    • Icon: Major Major
    • git-plugin
    • None
    • Jenkins 1.421 + git plugin 1.1.10

      This morning, we accidentally merged (on github' UI) one pull request to social client master. When I realized that, I reset --hard to the commit that is before the mis-merged commit and then force push (rewrite commit history).

      After that, we met this problem:

      1. The mis-merged commit is still there: https://ci.exoplatform.org/job/social-client-master-ci/changes SCL-14 | Switch to use TestNG instead of JUnit (commit: ad11e95eba2343fb8c14c04be981f74bc3035465) — hoatlevan / detail
      2. failed build with this: https://ci.exoplatform.org/view/%C2%B0%20IT%20%C2%B0/job/social-client-master-it/42/
        This is a matrix build. The parent went fine
        Started by upstream project "social-client-master-ci" build number 31
        Building on master
        Checkout:workspace / /home/swfhudson/data/jobs/social-client-master-it/workspace - hudson.remoting.LocalChannel@129a4ed
        Using strategy: Default
        Last Built Revision: Revision a63d278c2c0c2999b7686e86e4759bc4be902bb1 (origin/master)
        Checkout:workspace / /home/swfhudson/data/jobs/social-client-master-it/workspace - hudson.remoting.LocalChannel@129a4ed
        Fetching changes from 1 remote Git repository
        Fetching upstream changes from https://github.com/exosocial/exo.social.client.git
        Pruning obsolete local branches
        Commencing build of Revision 44bdde2ce4035bfd5fca0f81c18cd4d070f12135 (origin/master)
        Checking out Revision 44bdde2ce4035bfd5fca0f81c18cd4d070f12135 (origin/master)
        Cleaning workspace
        Triggering 1.2.1-SNAPSHOT
        Triggering 1.2.0-GA
        Triggering 1.3.0-SNAPSHOT
        Interrupting #42
        Finished: FAILURE
        

        But children builds failed, for example : https://ci.exoplatform.org/job/social-client-master-it/42/social.server.version=1.2.0-GA/console

        Started by upstream project "social-client-master-it" build number 42
        Building on master
        Checkout:1.2.0-GA / /home/swfhudson/data/jobs/social-client-master-it/workspace/social.server.version/1.2.0-GA - hudson.remoting.LocalChannel@129a4ed
        Using strategy: Default
        Last Built Revision: Revision a63d278c2c0c2999b7686e86e4759bc4be902bb1 (origin/master)
        Checkout:1.2.0-GA / /home/swfhudson/data/jobs/social-client-master-it/workspace/social.server.version/1.2.0-GA - hudson.remoting.LocalChannel@129a4ed
        Cloning the remote Git repository
        Cloning repository origin
        Fetching upstream changes from https://github.com/exosocial/exo.social.client.git
        Cleaning workspace
        Commencing build of Revision 44bdde2ce4035bfd5fca0f81c18cd4d070f12135 (origin/master)
        Checking out Revision 44bdde2ce4035bfd5fca0f81c18cd4d070f12135 (origin/master)
        Cleaning workspace
        FATAL: Could not checkout null with start point 44bdde2ce4035bfd5fca0f81c18cd4d070f12135
        hudson.plugins.git.GitException: Could not checkout null with start point 44bdde2ce4035bfd5fca0f81c18cd4d070f12135
        	at hudson.plugins.git.GitAPI.checkoutBranch(GitAPI.java:831)
        	at hudson.plugins.git.GitSCM$4.invoke(GitSCM.java:1143)
        	at hudson.plugins.git.GitSCM$4.invoke(GitSCM.java:1127)
        	at hudson.FilePath.act(FilePath.java:758)
        	at hudson.FilePath.act(FilePath.java:740)
        	at hudson.plugins.git.GitSCM.checkout(GitSCM.java:1127)
        	at hudson.model.AbstractProject.checkout(AbstractProject.java:1193)
        	at hudson.model.AbstractBuild$AbstractRunner.checkout(AbstractBuild.java:555)
        	at hudson.model.AbstractBuild$AbstractRunner.run(AbstractBuild.java:443)
        	at hudson.model.Run.run(Run.java:1376)
        	at hudson.matrix.MatrixRun.run(MatrixRun.java:146)
        	at hudson.model.ResourceController.execute(ResourceController.java:88)
        	at hudson.model.Executor.run(Executor.java:175)
        Caused by: hudson.plugins.git.GitException: Error performing command: git checkout -f 44bdde2ce4035bfd5fca0f81c18cd4d070f12135
        Command "git checkout -f 44bdde2ce4035bfd5fca0f81c18cd4d070f12135" returned status code 128: fatal: reference is not a tree: 44bdde2ce4035bfd5fca0f81c18cd4d070f12135
        
        	at hudson.plugins.git.GitAPI.launchCommandIn(GitAPI.java:744)
        	at hudson.plugins.git.GitAPI.launchCommand(GitAPI.java:709)
        	at hudson.plugins.git.GitAPI.launchCommand(GitAPI.java:719)
        	at hudson.plugins.git.GitAPI.checkoutBranch(GitAPI.java:818)
        	... 12 more
        Caused by: hudson.plugins.git.GitException: Command "git checkout -f 44bdde2ce4035bfd5fca0f81c18cd4d070f12135" returned status code 128: fatal: reference is not a tree: 44bdde2ce4035bfd5fca0f81c18cd4d070f12135
        
        	at hudson.plugins.git.GitAPI.launchCommandIn(GitAPI.java:739)
        	... 15 more
        

          [JENKINS-10385] FATAL: Could not checkout null with start point after a reset --hard to remove a commit

          I downgraded to 1.1.9, ~12 hours ago and for now I didn't see the problem back.
          I'll inform you if it will be always the case in 24h

          Arnaud Héritier added a comment - I downgraded to 1.1.9, ~12 hours ago and for now I didn't see the problem back. I'll inform you if it will be always the case in 24h

          Andrew Bayer added a comment -

          Fairly sure this is the same DefaultBuildChooser problem as 1.1.10 - could you try 1.1.11 once it shows up in the Update Center?

          Andrew Bayer added a comment - Fairly sure this is the same DefaultBuildChooser problem as 1.1.10 - could you try 1.1.11 once it shows up in the Update Center?

          For now I didn't reproduce this error with 1.1.11
          thx

          Arnaud Héritier added a comment - For now I didn't reproduce this error with 1.1.11 thx

          eguess74 added a comment -

          We just hit this problem with one of the jobs. The scenario was that the faulty commit was pushed to the repo, it was built in Jenkins, then it was reset --hard to previous commit and force pushed. After that the workspace was wiped out and now I can't build the job because it complains that it can't find the last built revision which it tries to start with.

          Jenkins 1.509, git plugin 1.1.23

          eguess74 added a comment - We just hit this problem with one of the jobs. The scenario was that the faulty commit was pushed to the repo, it was built in Jenkins, then it was reset --hard to previous commit and force pushed. After that the workspace was wiped out and now I can't build the job because it complains that it can't find the last built revision which it tries to start with. Jenkins 1.509, git plugin 1.1.23

          eguess74 added a comment -

          It seems that last built revision is retained in Jenkins memory and there is no way to force git plugin to forget it in this particular scenario other then restart the whole server or delete and recreate the project.

          May be we could have a link in GUI (somewhere under git polling log) allowing to reset last built revision together with performing a reset --hard on the repo where all local branches will be reset to their remote counterparts state?

          eguess74 added a comment - It seems that last built revision is retained in Jenkins memory and there is no way to force git plugin to forget it in this particular scenario other then restart the whole server or delete and recreate the project. May be we could have a link in GUI (somewhere under git polling log) allowing to reset last built revision together with performing a reset --hard on the repo where all local branches will be reset to their remote counterparts state?

          Justin Hammond added a comment - - edited

          Just ran into this error. I will attempt restarting the server, but otherwise it's locked up.

          Edit:
          Alright I restarted my server and it didn't make a difference. I noticed that git was checking out origin/master but when it was building it was referencing origin1/master. I believe this was caused because I added a second git repo and removed it.

          The work around was to copy the job to a new one.

          Edit 2:
          I've been able to recreate this issue by creating a project that checks out from some repo, then in a bash script during the build process, performing a git clone on some other repo (it's crazy, yeah..).

          Justin Hammond added a comment - - edited Just ran into this error. I will attempt restarting the server, but otherwise it's locked up. Edit: Alright I restarted my server and it didn't make a difference. I noticed that git was checking out origin/master but when it was building it was referencing origin1/master. I believe this was caused because I added a second git repo and removed it. The work around was to copy the job to a new one. Edit 2: I've been able to recreate this issue by creating a project that checks out from some repo, then in a bash script during the build process, performing a git clone on some other repo (it's crazy, yeah..).

          David Sachdev added a comment -

          I also came across this issue after adding in a second repository to pull from, and then deleting it. Also the build was referred to as (master1/master) instead of master/master) like it was prior to the addition of the repo.

          I tried to:

          1) manually remove the Workspace - didn't work
          2) remove the workspace from Jenkins - didn't work
          3) copied the job to a new job - the new job worked just fine
          4) finally I decided to delete the builds since I had added in the second repo, hoping that whatever metadata referred to the other repo would be deleted from the jobs cache - and it worked beautifully.

          Now to better understand this problem...and make the correct modifications to my build to use two repos.

          David Sachdev added a comment - I also came across this issue after adding in a second repository to pull from, and then deleting it. Also the build was referred to as (master1/master) instead of master/master) like it was prior to the addition of the repo. I tried to: 1) manually remove the Workspace - didn't work 2) remove the workspace from Jenkins - didn't work 3) copied the job to a new job - the new job worked just fine 4) finally I decided to delete the builds since I had added in the second repo, hoping that whatever metadata referred to the other repo would be deleted from the jobs cache - and it worked beautifully. Now to better understand this problem...and make the correct modifications to my build to use two repos.

          eguess74 added a comment -

          I think I found a good workaround for the problem:
          When you have a faulty commit pushed and Jenkins already built, it instead of going into the project workspace and trying to reset --hard it there do the "git reset --hard" operation from the execute shell build step. IT will find the previous build revision no problem and then this command will put the project into the state you need and record that last build revision properly. There will be no issues!

          I hope that helps!

          eguess74 added a comment - I think I found a good workaround for the problem: When you have a faulty commit pushed and Jenkins already built, it instead of going into the project workspace and trying to reset --hard it there do the "git reset --hard" operation from the execute shell build step. IT will find the previous build revision no problem and then this command will put the project into the state you need and record that last build revision properly. There will be no issues! I hope that helps!

          Wannes Sels added a comment -

          probable root cause: DefaultBuildChooser returns lastBuildRevision when there are no changes. It should probably check if that revision still exists

          Wannes Sels added a comment - probable root cause: DefaultBuildChooser returns lastBuildRevision when there are no changes. It should probably check if that revision still exists

          Loic Dachary added a comment -

          Loic Dachary added a comment - I added a USD 500 bounty on this issue. https://freedomsponsors.org/issue/679/fatal-could-not-checkout-null-with-start-point-after-a-reset-hard-to-remove-a-commit

            Unassigned Unassigned
            aheritier Arnaud Héritier
            Votes:
            6 Vote for this issue
            Watchers:
            8 Start watching this issue

              Created:
              Updated: