我试图让Jenkins在Windows PC上工作,并发现子模块存在一个奇怪的问题。
我有一个包含三个子模块的git repo。过了一会儿,似乎我让Git自己在Jenkins上工作,所以正常的克隆工作。但是克隆没有克隆主仓库中的子模块,所以我选中了该框以递归更新子模块。
然而,当我开始工作时:
Started by user <User>
Building in workspace X:\Jenkins\<JobName>
- C:/Program Files/Git/bin/git.exe rev-parse --is-inside-work-tree # timeout=10
Fetching changes from the remote Git repository
- C:/Program Files/Git/bin/git.exe config remote.origin.url ssh://git@<server>/<repo>.git # timeout=10
Fetching upstream changes from ssh://git@<server>/<repo>.git
- C:/Program Files/Git/bin/git.exe --version # timeout=10
using GIT_SSH to set credentials
- C:/Program Files/Git/bin/git.exe fetch --tags --progress ssh://git@<server>/<repo>.git +refs/heads/*:refs/remotes/origin/*
- C:/Program Files/Git/bin/git.exe rev-parse "refs/remotes/origin/master^{commit}" # timeout=10
- C:/Program Files/Git/bin/git.exe rev-parse "refs/remotes/origin/origin/master^{commit}" # timeout=10
Checking out Revision b13204ee1c6717a82d1c7a17922f2a477efd119d (refs/remotes/origin/master)
Commit message: "testinggg.."
- C:/Program Files/Git/bin/git.exe config core.sparsecheckout # timeout=10
- C:/Program Files/Git/bin/git.exe checkout -f b13204ee1c6717a82d1c7a17922f2a477efd119d
- C:/Program Files/Git/bin/git.exe rev-list b13204ee1c6717a82d1c7a17922f2a477efd119d # timeout=10
- C:/Program Files/Git/bin/git.exe remote # timeout=10
- C:/Program Files/Git/bin/git.exe submodule init # timeout=10
- C:/Program Files/Git/bin/git.exe submodule sync # timeout=10
- C:/Program Files/Git/bin/git.exe config --get remote.origin.url # timeout=10
- C:/Program Files/Git/bin/git.exe submodule init # timeout=10
- C:/Program Files/Git/bin/git.exe config -f .gitmodules --get-regexp ^submodule\.(.*)\.url # timeout=10
- C:/Program Files/Git/bin/git.exe config --get submodule.top.url # timeout=10
- C:/Program Files/Git/bin/git.exe remote # timeout=10
- C:/Program Files/Git/bin/git.exe config --get remote.origin.url # timeout=10
- C:/Program Files/Git/bin/git.exe config -f .gitmodules --get submodule.top.path # timeout=10
using GIT_SSH to set credentials
- C:/Program Files/Git/bin/git.exe submodule update --init --recursive top
FATAL: Command "C:/Program Files/Git/bin/git.exe submodule update --init --recursive top" returned status code 1:
stdout:
stderr: fatal: Needed a single revision
Unable to find current revision in submodule path 'top'
hudson.plugins.git.GitException: Command "C:/Program Files/Git/bin/git.exe submodule update --init --recursive top" returned status code 1:
stdout:
stderr: fatal: Needed a single revision
Unable to find current revision in submodule path 'top'
at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.launchCommandIn(CliGitAPIImpl.java:1903)
at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.launchCommandWithCredentials(CliGitAPIImpl.java:1622)
at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.access$300(CliGitAPIImpl.java:71)
at org.jenkinsci.plugins.gitclient.CliGitAPIImpl$7.execute(CliGitAPIImpl.java:1076)
at hudson.plugins.git.extensions.impl.SubmoduleOption.onCheckoutCompleted(SubmoduleOption.java:102)
at hudson.plugins.git.GitSCM.checkout(GitSCM.java:1182)
at hudson.scm.SCM.checkout(SCM.java:495)
at hudson.model.AbstractProject.checkout(AbstractProject.java:1276)
at hudson.model.AbstractBuild$AbstractBuildExecution.defaultCheckout(AbstractBuild.java:560)
at jenkins.scm.SCMCheckoutStrategy.checkout(SCMCheckoutStrategy.java:86)
at hudson.model.AbstractBuild$AbstractBuildExecution.run(AbstractBuild.java:485)
at hudson.model.Run.execute(Run.java:1735)
at hudson.model.FreeStyleBuild.run(FreeStyleBuild.java:43)
at hudson.model.ResourceController.execute(ResourceController.java:97)
at hudson.model.Executor.run(Executor.java:405)
Finished: FAILURE
Git在说:
时的意思是什么需要单个版本无法在子模块路径中找到当前版本&#39; top&#39;
我环顾四周,一无所获:(
我在普通的shell上复制了这个命令序列,没有出现错误。
任何帮助将不胜感激。谢谢!
答案 0 :(得分:1)
对于遇到类似问题的任何人,请选中Jenkins框以清除本地工作区并强制存储库克隆一次。这对我有用;)
答案 1 :(得分:0)
显然&#39; top&#39;是你的子模块之一。包含子模块的主存储库只存储每个子模块的提交ID作为对它们的引用。我将错误消息解释为好像有一个提交ID为&#39; top&#39;在顶部&#39;中无法找到(不存在?)的主回购中。我检查一下以确定这一点。
在我使用Git子模块和Jenkins的最后一个项目中,我们没有使用Git插件的 高级子模块行为 ,但执行了所有项目Conditional BuildStep Plugin中 Builder:执行shell 步骤中的latest_question_list = Question.objects.order_by('-pub_date')[:5]
命令。 条件,如果在这些Git命令期间出现问题,则能够中止构建。
答案 2 :(得分:0)
top
分支sha与子模块的提交sha不匹配。
考虑启用“将跟踪子模块更新到分支的尖端”选项。
这可能不适用于标签。