git子模块更新失败

git子模块更新失败

本文介绍了Jenkins git子模块更新失败的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个有一个子模块的git repo。两人都属于BitBucket团队。我的jenkins机器是一个带有git插件的AWS windows服务器。我正在使用SSH密钥进行身份验证。
我有三个jenkins工作。一个克隆主要回购。这是成功的。一个克隆自己的第二个回购(将用作子模块的回购)。这也是成功的。
在我的第三个构建作业中,我告诉jenkins递归地更新子模块。这失败了,并说公钥失误。如果我可以自行克隆回购,情况如何?

I have a git repo which has one submodule. Both belong to a team on BitBucket. My jenkins machine is a AWS windows server with the git plugin. I am using SSH keys for authentication.I have three jenkins jobs. One clones the main repo. This is successful. One clones the second repo on its own (the repo which will be used as a submodule). This is also successful.In my third build job I tell jenkins to recursively update the submodules. This fails and says public-key error. How can this be the case if I can clone the repo on its own?

以下控制台输出:

Started by user anonymous
Building on master in workspace C:\Program Files (x86)\Jenkins\jobs\MainRepo\workspace
Wiping out workspace first.
Cloning the remote Git repository
Cloning repository [email protected]:team/mainrepo.git
 > git.exe init C:\Program Files (x86)\Jenkins\jobs\mainrepo\workspace # timeout=10
Fetching upstream changes from [email protected]:team/mainrepo.git
 > git.exe --version # timeout=10
using GIT_SSH to set credentials
 > git.exe -c core.askpass=true fetch --tags --progress [email protected]:team/mainrepo.git +refs/heads/*:refs/remotes/origin/*
 > git.exe config remote.origin.url [email protected]:team/mainrepo.git # timeout=10
 > git.exe config --add remote.origin.fetch +refs/heads/*:refs/remotes/origin/* # timeout=10
 > git.exe config remote.origin.url [email protected]:team/mainrepo.git # timeout=10
Fetching upstream changes from [email protected]:team/mainrepo.git
using GIT_SSH to set credentials
 > git.exe -c core.askpass=true fetch --tags --progress [email protected]:team/mainrepo.git +refs/heads/*:refs/remotes/origin/*
 > git.exe rev-parse "refs/remotes/origin/master^{commit}" # timeout=10
 > git.exe rev-parse "refs/remotes/origin/origin/master^{commit}" # timeout=10
Checking out Revision 6b3f6535c45e79ee88f4918d464edead48d83369 (refs/remotes/origin/master)
 > git.exe config core.sparsecheckout # timeout=10
 > git.exe checkout -f 6b3f6535c45e79ee88f4918d464edead48d83369
 > git.exe rev-list 6b3f6535c45e79ee88f4918d464edead48d83369 # timeout=10
 > git.exe remote # timeout=10
 > git.exe submodule init # timeout=10
 > git.exe submodule sync # timeout=10
 > git.exe config --get remote.origin.url # timeout=10
 > git.exe submodule update --init --recursive
FATAL: Command "git.exe submodule update --init --recursive" returned status code 128:
stdout:
stderr: Cloning into 'my-submodule'...
Permission denied (publickey).
fatal: Could not read from remote repository.

Please make sure you have the correct access rights
and the repository exists.
fatal: clone of '[email protected]:team/my-submodule.git' into submodule path 'my-submodule' failed

hudson.plugins.git.GitException: Command "git.exe submodule update --init --recursive" returned status code 128:
stdout:
stderr: Cloning into 'my-submodule'...
Permission denied (publickey).
fatal: Could not read from remote repository.

Please make sure you have the correct access rights
and the repository exists.
fatal: clone of '[email protected]:team/my-submodule.git' into submodule path 'my-submodule' failed

    at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.launchCommandIn(CliGitAPIImpl.java:1693)
    at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.access$500(CliGitAPIImpl.java:62)
    at org.jenkinsci.plugins.gitclient.CliGitAPIImpl$7.execute(CliGitAPIImpl.java:953)
    at hudson.plugins.git.extensions.impl.SubmoduleOption.onCheckoutCompleted(SubmoduleOption.java:90)
    at hudson.plugins.git.GitSCM.checkout(GitSCM.java:1098)
    at hudson.scm.SCM.checkout(SCM.java:485)
    at hudson.model.AbstractProject.checkout(AbstractProject.java:1276)
    at hudson.model.AbstractBuild$AbstractBuildExecution.defaultCheckout(AbstractBuild.java:607)
    at jenkins.scm.SCMCheckoutStrategy.checkout(SCMCheckoutStrategy.java:86)
    at hudson.model.AbstractBuild$AbstractBuildExecution.run(AbstractBuild.java:529)
    at hudson.model.Run.execute(Run.java:1738)
    at hudson.matrix.MatrixBuild.run(MatrixBuild.java:301)
    at hudson.model.ResourceController.execute(ResourceController.java:98)
    at hudson.model.Executor.run(Executor.java:410)
Finished: FAILURE


推荐答案

是jenkins中的一个已知错误:,但现在已经修复,请更新您的Git插件来解决问题。

This was a known bug in jenkins: https://issues.jenkins-ci.org/browse/JENKINS-20941 but it has now been fixed, update your Git plugin to resolve the issue.

如果更新不可行,作为解决方法,您可以将密钥放在jenkins-users .ssh文件夹中。

If updating is not possible, as a workaround, you could put the key in jenkins-users .ssh folder.

这篇关于Jenkins git子模块更新失败的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-24 05:02