我正在使用Jenkins构建一个具有多个Git子模块的项目。虽然可以获取主存储库,但子模块初始化失败,即使是在新的克隆上:
Started by user anonymous
[EnvInject] - Loading node environment variables.
Building in workspace C:\Builds\Test Build
[WS-CLEANUP] Deleting project workspace...
[WS-CLEANUP] Done
Wiping out workspace first.
Cloning the remote Git repository
Cloning repository git@bitbucket.org:ACCOUNT/MAIN_REPOSITORY.git
> C:\Program Files\Git\mingw64\bin\git.exe init C:\Builds\Test Build # timeout=10
Fetching upstream changes from git@bitbucket.org:ACCOUNT/MAIN_REPOSITORY.git
> C:\Program Files\Git\mingw64\bin\git.exe --version # timeout=10
using GIT_SSH to set credentials Matt's Bitbucket SSH key
> C:\Program Files\Git\mingw64\bin\git.exe fetch --tags --progress git@bitbucket.org:ACCOUNT/MAIN_REPOSITORY.git +refs/heads/*:refs/remotes/origin/* # timeout=20
> C:\Program Files\Git\mingw64\bin\git.exe config remote.origin.url git@bitbucket.org:ACCOUNT/MAIN_REPOSITORY.git # timeout=10
> C:\Program Files\Git\mingw64\bin\git.exe config --add remote.origin.fetch +refs/heads/*:refs/remotes/origin/* # timeout=10
> C:\Program Files\Git\mingw64\bin\git.exe config remote.origin.url git@bitbucket.org:ACCOUNT/MAIN_REPOSITORY.git # timeout=10
Fetching upstream changes from git@bitbucket.org:ACCOUNT/MAIN_REPOSITORY.git
using GIT_SSH to set credentials Matt's Bitbucket SSH key
> C:\Program Files\Git\mingw64\bin\git.exe fetch --tags --progress git@bitbucket.org:ACCOUNT/MAIN_REPOSITORY.git +refs/heads/*:refs/remotes/origin/* # timeout=20
> C:\Program Files\Git\mingw64\bin\git.exe rev-parse "origin/master^{commit}" # timeout=10
Checking out Revision COMMIT_HASH (origin/master)
Commit message: "Updated Submodules"
> C:\Program Files\Git\mingw64\bin\git.exe config core.sparsecheckout # timeout=10
> C:\Program Files\Git\mingw64\bin\git.exe checkout -f COMMIT_HASH
First time build. Skipping changelog.
> C:\Program Files\Git\mingw64\bin\git.exe remote # timeout=10
> C:\Program Files\Git\mingw64\bin\git.exe submodule init # timeout=10
FATAL: Command "C:\Program Files\Git\mingw64\bin\git.exe submodule init" returned status code 128:
stdout:
stderr: fatal: 'submodule' appears to be a git command, but we were not
able to execute it. Maybe git-submodule is broken?
hudson.plugins.git.GitException: Command "C:\Program Files\Git\mingw64\bin\git.exe submodule init" returned status code 128:
stdout:
stderr: fatal: 'submodule' appears to be a git command, but we were not
able to execute it. Maybe git-submodule is broken?
at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.launchCommandIn(CliGitAPIImpl.java:1924)
at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.launchCommandIn(CliGitAPIImpl.java:1892)
at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.launchCommandIn(CliGitAPIImpl.java:1888)
at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.launchCommand(CliGitAPIImpl.java:1533)
at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.launchCommand(CliGitAPIImpl.java:1545)
at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.submoduleInit(CliGitAPIImpl.java:945)
at org.jenkinsci.plugins.gitclient.LegacyCompatibleGitAPIImpl.setupSubmoduleUrls(LegacyCompatibleGitAPIImpl.java:81)
at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.setupSubmoduleUrls(CliGitAPIImpl.java:71)
at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.setupSubmoduleUrls(CliGitAPIImpl.java:1417)
at hudson.plugins.git.extensions.impl.SubmoduleOption.onCheckoutCompleted(SubmoduleOption.java:100)
at hudson.plugins.git.GitSCM.checkout(GitSCM.java:1188)
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.matrix.MatrixBuild.run(MatrixBuild.java:313)
at hudson.model.ResourceController.execute(ResourceController.java:97)
at hudson.model.Executor.run(Executor.java:405)
Finished: FAILURE
从Git Bash运行“git submodule init”按预期工作 我可能缺少什么让Jenkins表现得正确?
这看起来不同于:
最新的工具版本似乎已修复已知的子模块错误。 我试过以下没有任何影响:
答案 0 :(得分:1)
我在Windows 10和Linux(Ubuntu 17.04)中构建了这个项目进行测试。在这两种情况下,我都直接在Jenkins中指定了SSH密钥,并专门从〜/ .ssh
中删除了它Windows 10无法构建,类似于上面的列表。 Linux毫无问题地克隆了父模块和子模块存储库。
鉴于这些结果,我得出结论,该问题特定于Windows + GitPlugin。
答案 1 :(得分:1)
git插件使用了错误的git.exe。它已配置为使用git.exe:
C:\Program Files\Git\Mingw64\bin\git.exe
该位置的git.exe显然无法找到子模块命令。
配置git插件以使用默认位置的git.exe,它将按预期工作。默认位置为:
C:\Program Files\Git\bin\git.exe
如果我使用失败的PATH设置配置Windows命令提示符,它会报告相同的消息
致命:'子模块'似乎是一个git命令,但我们无法执行它。
如果我使用工作路径设置配置Windows命令提示符,则git submodule命令将按预期运行。
为什么会发生这种情况
可能是您的git命令的位置已在Jenkins中定义(错误地)为
C:\Program Files\Git\Mingw64\bin\git.exe
可能是PATH环境变量包含mingw64目录。
答案 2 :(得分:0)