3

Okay, firstly, I am very new to git.

I have set up a build, however it has just started failing, with the following error.

FATAL: Command "git submodule update" returned status code 1:
stdout: 
stderr: fatal: reference is not a tree: 72294b9c60128b4495dfe0bf3aa014b3bf1853e9
Unable to checkout '72294b9c60128b4495dfe0bf3aa014b3bf1853e9' in submodule path 'sub/Android-ViewPagerIndicator'

hudson.plugins.git.GitException: Command "git submodule update" returned status code 1:
stdout: 
stderr: fatal: reference is not a tree: 72294b9c60128b4495dfe0bf3aa014b3bf1853e9
Unable to checkout '72294b9c60128b4495dfe0bf3aa014b3bf1853e9' in submodule path 'sub/Android-ViewPagerIndicator'

    at hudson.plugins.git.GitAPI.launchCommandIn(GitAPI.java:838)
    at hudson.plugins.git.GitAPI.launchCommand(GitAPI.java:800)
    at hudson.plugins.git.GitAPI.submoduleUpdate(GitAPI.java:429)
    at hudson.plugins.git.GitSCM$4.invoke(GitSCM.java:1308)
    at hudson.plugins.git.GitSCM$4.invoke(GitSCM.java:1269)
    at hudson.FilePath.act(FilePath.java:851)
    at hudson.FilePath.act(FilePath.java:824)
    at hudson.plugins.git.GitSCM.checkout(GitSCM.java:1269)
    at hudson.model.AbstractProject.checkout(AbstractProject.java:1325)
    at hudson.model.AbstractBuild$AbstractBuildExecution.defaultCheckout(AbstractBuild.java:676)
    at jenkins.scm.SCMCheckoutStrategy.checkout(SCMCheckoutStrategy.java:88)
    at hudson.model.AbstractBuild$AbstractBuildExecution.run(AbstractBuild.java:581)
    at hudson.model.Run.execute(Run.java:1516)
    at hudson.model.FreeStyleBuild.run(FreeStyleBuild.java:46)
    at hudson.model.ResourceController.execute(ResourceController.java:88)
    at hudson.model.Executor.run(Executor.java:236)
Alexander Bird
  • 33,259
  • 40
  • 118
  • 154
serenskye
  • 3,297
  • 4
  • 30
  • 49
  • so would you mind sharing how you've set up the build? – eis Nov 19 '12 at 15:57
  • I'm using a git plugin for jenkins and github. The repo has 4 submodules. (I didn't set this up). The build script: PATH=/Applications/android/tools/:$PATH PATH=/Applications/android/platform-tools/:$PATH android update project --path . --subprojects --target android-16 cd app; rake build:debug – serenskye Nov 20 '12 at 13:20
  • Ok, so how about the jenkins/hudson *job* details? Things like what kind of SCM url you have, what kind of refspec, do you use tagging and if you have, do you need it etc. – eis Nov 20 '12 at 16:09
  • also, if you clean your job every time you do a build or do you build on top of previous checkout. If it would recreate it every time, does that fix it? – eis Nov 20 '12 at 16:10

2 Answers2

3

Someone has messed up your submodule reference in your master project. Basically, your master repo always refers to a specific commit in your submodule repo, and the commit the references one of your submodules (72294b9c60128b4495dfe0bf3aa014b3bf1853e9) does not seem to exist.

This can happen if 1) someone has made a checkin in the submodule project with its head detached or 2) the submodule project itself has been changed in a way it doesn't contain the commit anymore.

The problem should however show up outside Hudson, too, whereever you do a clone of your project. If it doesn't it may be that just your Hudson clone is corrupted and can be just deleted and recreated. That might be feasible to test also.

If that doesn't do anything and you really need to fix the things, check out this thread for solutions, and you can also go through this blog post for more details.

As a personal opinion, submodules are easy to break. You should avoid touching those if you are "very new to git", but get your feet wet with git overall usage first.

Community
  • 1
  • 1
eis
  • 45,245
  • 11
  • 129
  • 177
  • It only happens via jenkins builds. It didn't happen on the first couple but always seems to happen after a few builds. I can't change the git setup, its a large project with other devs, I'm just looking at the build. Thanks for the links, I'll take a look :) – serenskye Nov 20 '12 at 14:27
  • So looks like I can't use the git plugin for jenkins because the update triggers this all off!? – serenskye Nov 20 '12 at 14:39
0

This thread is a few years old, but I experienced the same problem and I wanted to share how I solved it.

My issue had nothing to do with the missing commit that many have mentioned here and elsewhere, it has instead to do with the internals of Hudson/Jenkins, namely how Git data is stored in a temporary workspace directory: if that becomes somehow accessible, the submodule update would fail.

So my workaround was to use an explicit RelativeTargetDirectory next to the the CloneOption and SubmoduleOption in the extensions of the checkout construct (here superproject is the name of the project with submodules, and BRANCH_NAME is given as environment variable):

checkout([
    $class: 'GitSCM',
    branches: [[name: '${BRANCH_NAME}']],
    doGenerateSubmoduleConfigurations: false,
    extensions: [[
        $class: 'RelativeTargetDirectory',
        relativeTargetDir: 'superproject'
    ], [
        $class: 'CleanBeforeCheckout'
    ], [
        $class: 'CloneOption',
        honorRefspec: true, noTags: true, reference: '', shallow: true
    ], [
        $class: 'SubmoduleOption',
        disableSubmodules: false, parentCredentials: true, recursiveSubmodules: false,
        reference: '', trackingSubmodules: false
    ]],
    submoduleCfg: [],
    userRemoteConfigs: [[
        credentialsId: '...',
        url: 'https://.../superproject.git']]
])

As a result of this step, you should see that a folder named superproject@tmp is created alongside the main folder named superproject in your Jenkins/Hudson workspace

Raffaele N.
  • 606
  • 5
  • 3