更新子模块时 Git on Hudson 致命异常



好的,首先,我对git很陌生。

我已经设置了一个构建,但是它刚刚开始失败,并出现以下错误。

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)

有人搞砸了主项目中的子模块引用。基本上,您的主存储库总是引用子模块存储库中的特定提交,并且提交引用其中一个子模块(72294b9c60128b4495dfe0bf3aa014b3bf1853e9)似乎不存在。

如果 1) 有人在子模块项目中签入,其头部分离,或者 2) 子模块项目本身已以不再包含提交的方式进行了更改,则可能会发生这种情况。

然而,问题也应该出现在哈德逊之外,无论你在哪里克隆你的项目。如果没有,则可能只有您的Hudson克隆已损坏,可以删除并重新创建。测试起来也可能是可行的。

如果这没有任何作用并且您确实需要解决这些问题,请查看此线程以获取解决方案,您也可以浏览此博客文章以获取更多详细信息。

作为个人观点,子模块很容易被打破。如果你"对 git 很陌生",你应该避免触摸这些,但首先要用 git 的整体用法弄湿你的脚。

这个线程已经有几年的历史了,但我遇到了同样的问题,我想分享我是如何解决它的。

我的问题与许多人在这里和其他地方提到的缺失提交无关,而是与 Hudson/Jenkins 的内部结构有关,即 Git 数据存储在临时工作区目录中的方式:如果以某种方式可访问,子模块更新将失败。

所以我的解决方法是在结帐构造的扩展中的CloneOptionSubmoduleOption旁边使用显式RelativeTargetDirectory(这里superproject是带有子模块的项目的名称,BRANCH_NAME作为环境变量给出):

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']]
])

作为此步骤的结果,您应该会看到一个名为superproject@tmp的文件夹与 Jenkins/Hudson 工作区中名为superproject的主文件夹一起创建

最新更新