Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/jenkins/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Jenkins Git插件无法初始化子模块_Git_Jenkins_Ssh_Bitbucket - Fatal编程技术网

Jenkins Git插件无法初始化子模块

Jenkins Git插件无法初始化子模块,git,jenkins,ssh,bitbucket,Git,Jenkins,Ssh,Bitbucket,我正在使用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 ou

我正在使用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”可以正常工作。
要让詹金斯举止得体,我可能缺少什么?

配置:
  • 视窗7
  • 詹金斯2.73.1
  • Git插件2.5.0
  • Git客户端插件3.5.1
  • Git for Windows 2.14.1.Windows.1
  • 主存储库和子模块是同一帐户下Bitbucket中的私有Git存储库,ssh密钥已经交换
  • 高级子模块行为选项:
    • “反方向udpate子模块”
    • “使用来自父存储库的默认远程存储库的凭据”
这似乎与以下两种情况不同:

最新的工具版本似乎已经修复了已知的子模块错误。 我尝试了以下方法,但没有任何效果:

  • 使用Jenkins存储的SSH密钥与~/.SSH本地密钥
  • 使用基于HTTPS的repo访问而不是ssh
  • 在.git模块中使用相对路径而不是绝对路径
  • 使用托管在GitHub上的repos而不是BitBucket

  • 你确认你的git是正确的吗?

    你试过-


    我在Windows 10和Linux(Ubuntu 17.04)中构建了这个项目以进行测试。在这两种情况下,我都直接在Jenkins中指定了SSH密钥,并专门将其从~/.SSH中删除

    Windows 10无法构建,类似于上面的清单。 Linux克隆父模块和子模块repo,没有问题


    根据这些结果,我得出结论,问题出在Windows+GitPlugin上。

    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
    
    如果我使用失败的路径设置配置Windows命令提示符,它会报告相同的消息

    致命:“子模块”似乎是git命令,但我们无法执行它

    如果使用工作路径设置配置Windows命令提示符,git子模块命令的行为将与预期的一样

    为什么会发生这种情况

    可能是git命令的位置在Jenkins中被(错误地)定义为

    C:\Program Files\Git\Mingw64\bin\git.exe
    

    可能是PATH环境变量包含mingw64目录。

    Jenkins/Git正确地进行身份验证并从Bitbucket获取主存储库,因此我确信URL和身份验证是正确的。手动执行“git submodule init”有效,因此.gtimodule URL也正确。因此,如果没有Jenkins,它也可以工作,您是否验证它是相同的git版本和git用户?我已确认Jenkins正在调用Windows git.exe,并且它是安装的git的唯一版本。Jenkins是作为本地系统登录的服务运行的;此系统当前只有一个(管理员)帐户。在我运行的实验中,它读取用户的本地.ssh密钥进行身份验证,以确认它使用的是正确的用户。问题似乎与Jenkins/子模块交叉产品无关。您是否用子模块标记了高级签出选项?是的,如上面的“配置”中所列。