1

On Jenkins I get an error

Checking out Revision 028951e3660cfba709acb85d4620ce071f89451b (origin/JenkinsTest)
Enabling Git LFS pull
> git.exe config core.sparsecheckout # timeout=10
> git.exe checkout -f 028951e3660cfba709acb85d4620ce071f89451b
FATAL: Could not checkout 028951e3660cfba709acb85d4620ce071f89451b
hudson.plugins.git.GitException: Command "git.exe checkout -f 028951e3660cfba709acb85d4620ce071f89451b" returned status code 128:
stdout: 
stderr: fatal: reference is not a tree: 028951e3660cfba709acb85d4620ce071f89451b

    at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.launchCommandIn(CliGitAPIImpl.java:1990)
    at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.access$800(CliGitAPIImpl.java:72)
    at org.jenkinsci.plugins.gitclient.CliGitAPIImpl$9.execute(CliGitAPIImpl.java:2289)
Caused: hudson.plugins.git.GitException: Could not checkout 028951e3660cfba709acb85d4620ce071f89451b
    at org.jenkinsci.plugins.gitclient.CliGitAPIImpl$9.execute(CliGitAPIImpl.java:2313)
    at hudson.plugins.git.GitSCM.checkout(GitSCM.java:1210)
    at hudson.scm.SCM.checkout(SCM.java:495)
    at hudson.model.AbstractProject.checkout(AbstractProject.java:1202)
    at hudson.model.AbstractBuild$AbstractBuildExecution.defaultCheckout(AbstractBuild.java:574)
    at jenkins.scm.SCMCheckoutStrategy.checkout(SCMCheckoutStrategy.java:86)
    at hudson.model.AbstractBuild$AbstractBuildExecution.run(AbstractBuild.java:499)
    at hudson.model.Run.execute(Run.java:1724)
    at hudson.model.FreeStyleBuild.run(FreeStyleBuild.java:43)
    at hudson.model.ResourceController.execute(ResourceController.java:97)
    at hudson.model.Executor.run(Executor.java:421)

Sending e-mails to: xxxxxxxxxxxxxxxxx
Finished: FAILURE

The Problem is the following:
We use our own Gitlab-Server and the repository is importet from github.

For testing I created the branch "origin/jenkinsTest" which is refered in the error on Gitlab.

After testing I deleted the repository on gitlab and importet as newly from github. Now ofcourse there is no branch "origin/jenkinsTest" anymore.

I already removed the workspace on Jenkins for this repository but it keeps failing with this error.

How can I fix this?


On another PC I can clone the repository from Gitlab perfectly, so it can not be a failure on the Gitlab-Server but has to be on the Jenkins-Server (Windows 10).


EDIT
Running git branch -r on another clone as suggested in the comments gave me

origin/BugFixing
origin/CoroutinesDisableButtons
origin/GestureRotation
origin/MovePanelsOnMove
origin/NewNetworking
origin/RebuildUIWithPrefabs
origin/ShowSimpleModelsOnly
origin/SourceLostBug
origin/States_Management
origin/SwitchToplayers
origin/UI-Panels
origin/UIFeinschliff
origin/master

And actually just before the error from above I also see it like this in the Jenkins output:

Seen branch in repository origin/BugFixing
Seen branch in repository origin/CoroutinesDisableButtons
Seen branch in repository origin/GestureRotation
Seen branch in repository origin/MovePanelsOnMove
Seen branch in repository origin/NewNetworking
Seen branch in repository origin/RebuildUIWithPrefabs
Seen branch in repository origin/ShowSimpleModelsOnly
Seen branch in repository origin/SourceLostBug
Seen branch in repository origin/States_Management
Seen branch in repository origin/SwitchToplayers
Seen branch in repository origin/UI-Panels
Seen branch in repository origin/UIFeinschliff
Seen branch in repository origin/master
 seen 13 remote branches
 > git.exe show-ref --tags -d # timeout=10

EDIT 2
I create and configured a New Job with different Name and this one clone/checkout/pull the git just fine while using the original Job it still fails. (I'm letting Jenkins clean the workspace before build and also deletet the complete workspace folder manually).

Is there maybe any data about the Job/Git stored outside the workspace folder?!

derHugo
  • 49,310
  • 9
  • 37
  • 73
  • which branch are you checking out on jenkins from gitlab? – lvthillo Jan 16 '18 at 06:41
  • I left it "Blank for any" so it gets `**` – derHugo Jan 16 '18 at 13:15
  • what is the output of git branch -r after you clone the repo locally? Is the JenkinsTest branch really gone? Cloning locally (probably one branch) is different then checking out every branch like your jenkins is doing. – lvthillo Jan 16 '18 at 13:19
  • @lvthillo it gives me the same branches which are on Gitlab and which are supposed to be there .. and the "JenkinsTest" branch is not one of them – derHugo Jan 16 '18 at 13:37
  • I think this can help you: https://stackoverflow.com/questions/2155887/git-submodule-head-reference-is-not-a-tree-error – lvthillo Jan 16 '18 at 14:06

2 Answers2

1

The only thing that solved this issue was to remove the entire job-definition (not only the workspace) and create a new one with the same settings. Now it clones and builds all fine.

So it seems to be aproved that somewhere Jenkins stored more information about the git repository than only in the job's workspace.

I've seen that the job-definitions themselves are stored under <JenkinsInstall>\Jobs and probably there was also the information about former pulled branches stored together with the former builds information.

derHugo
  • 49,310
  • 9
  • 37
  • 73
0

Remove the old project in the workspace and run the test again to clone and to run the test

Sonali
  • 553
  • 2
  • 20
  • 1
    Please see in the question description `I'm letting Jenkins clean the workspace before build and also deletet the complete workspace folder manually` – derHugo Sep 11 '20 at 15:51