【问题标题】:Could not clone remote repository无法克隆远程存储库
【发布时间】:2013-07-18 08:33:07
【问题描述】:

我在 Red Hat Enterprise 5 中运行 Hudson。在 Hudson 中,我使用 Git 克隆远程存储库。克隆代码时出现此错误:

Cloning the remote Git repository
Cloning repository origin
ERROR: Error cloning remote repo 'origin' 
hudson.plugins.git.GitException: Could not clone <repo url>
    at hudson.plugins.git.GitAPI.clone(GitAPI.java:241)
    at hudson.plugins.git.GitSCM$3.invoke(GitSCM.java:972)
    at hudson.plugins.git.GitSCM$3.invoke(GitSCM.java:919)
    at hudson.FilePath.act(FilePath.java:791)
    at hudson.FilePath.act(FilePath.java:773)
    at hudson.plugins.git.GitSCM.gerRevisionToBuild(GitSCM.java:919)
    at hudson.plugins.git.GitSCM.checkout(GitSCM.java:698)
    at hudson.model.AbstractProject.checkout(AbstractProject.java:1515)
    at hudson.model.AbstractBuild$AbstractRunner.checkout(AbstractBuild.java:521)
    at hudson.model.AbstractBuild$AbstractRunner.run(AbstractBuild.java:428)
    at hudson.model.Run.run(Run.java:1390)
    at hudson.model.FreeStyleBuild.run(FreeStyleBuild.java:40)
    at hudson.model.ResourceController.execute(ResourceController.java:82)
    at hudson.model.Executor.run(Executor.java:137)
Caused by: hudson.plugins.git.GitException: org.eclipse.jgit.api.errors.TransportException: <repo   url>: not authorized
    at hudson.plugins.git.GitAPI$1.invoke(GitAPI.java:234)
    at hudson.plugins.git.GitAPI$1.invoke(GitAPI.java:221)
    at hudson.FilePath.act(FilePath.java:791)
    at hudson.FilePath.act(FilePath.java:773)
    at hudson.plugins.git.GitAPI.clone(GitAPI.java:221)
    ... 13 more

我在上面的跟踪中看到“未授权”,所以我猜这可能是因为我没有设置 Git 帐户(用户名/密码)。我在 Hudson 的配置和作业的配置中搜索了每个配置,但找不到指定密码的位置。请帮帮我!

【问题讨论】:

  • &lt;repo url&gt; 网址似乎为空。这是正常的还是出于保密原因,您是否从该问题的输出中删除了它?
  • 是的,出于保密考虑,我删除了它

标签: git hudson redhat


【解决方案1】:

AFAIK,Hudson 作为单独的用户运行,因此当 Hudson 尝试克隆某些内容时,它会搜索私钥进行身份验证。

你应该,

以 root 身份切换

$sudo -i

然后切换为 hudson 用户

$su hudson

生成 ssh 密钥

$ssh-keygen -t rsa -C 'email_id_for_authentication'

从 ~hudson(hudson 用户的主文件夹)中的 .ssh 文件夹中复制公钥

将其添加到您的远程存储库。

在用户 hudosn 中为 git 设置 user.email

$git config --global user.email "email_id_for_authentication"

你可以在Manage Hudson &gt; Configure System的git-plugin配置下做同样的事情

【讨论】:

  • 问题是我不能将任何东西放到远程存储库中。有没有像在 Windows 中那样的另一种方法,我只是将用户名/密码放在 _netrc 文件中,我可以克隆任何远程代码。
  • 它是一种双向认证,远程需要知道连接的 ssh 客户端是经过认证的,所以它需要你的公钥。 B/w 你在谈论公共 github 回购吗?如果是这样,请使用 https 而不是 git/ssh 协议作为 repo url。
  • 它是需要用户名/密码的私有 github 仓库
猜你喜欢
  • 2021-04-16
  • 1970-01-01
  • 1970-01-01
  • 2015-02-27
  • 2017-10-17
  • 2016-10-09
  • 2015-05-16
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多