【问题标题】:Jenkins Failed to Connect to RepositoryJenkins 无法连接到存储库
【发布时间】:2016-04-04 13:13:05
【问题描述】:

我正在尝试将 Jenkins 连接到私有 BitBucket 存储库。

我有一组在/var/lib/jenkins/.ssh 生成的 SSH 密钥(id_rsa 和 id_rsa.pub)。我已复制 id_rsa.pub 密钥并将其粘贴到我的 BitBucket 存储库的部署密钥部分。类似地,运行命令git ls-remote -h git@bitbucket.org:user/project.git 有一个有效的返回并已添加到known_hosts

什么可能导致我的 Jenkins 无法连接到 Jenkins 的 git 源代码管理部分?返回的错误是:

无法连接到存储库:命令“git -c core.askpass=true ls-remote -h https://git@bitbucket.org/user/project.git HEAD”返回状态码 128: 标准输出: 标准错误:远程:用户名或密码无效。如果您通过第三方服务登录,您必须确保在您的帐户资料中设置了帐户密码。 致命:“https://git@bitbucket.org/user/project.git/”的身份验证失败

我还按照 Atlassian 的 this doc 尝试了 ssh -Tv git@bitbucket.org,以解决 SSH 问题。返回状态如下:

此部署密钥对以下存储库具有读取权限:

用户/项目:Jenkins -- jenkins@ip-xxx-xx-xx-xxx

【问题讨论】:

  • 所以我犯了一个愚蠢的错误,并使用 https://git@bitbucket.org/user/project.git 作为存储库 URL 而不是 git@bitbucket.org:user/project.git facepalm 将其更改为后者即可,无需填写凭据(假设 SSH 已成功设置)。
  • 请添加您的评论作为解决方案并将其标记为已解决:)
  • 您应该将其添加为分析器 @Xenyal 。我在 GitHub 上犯了同样的错误。
  • JoSSI 和 @angryip 感谢您提出这个问题。我已将其添加为可接受的解决方案。

标签: jenkins ssh bitbucket


【解决方案1】:

对于 Jenkins 的 Git Plugin 提供的 Project Repository 字段,他们的主页中显示的该字段的示例之一(特别是 https://git@bitbucket.org/user/project.git)似乎不起作用。这可能是插件版本的情况,或者 BitBucket 的配置方式可能与 GitHub 不同,他们的文档使用 GitHub 作为示例。

然而,对我有用的是使用以下格式的 git 地址:

git@bitbucket.org:user/project.git

【讨论】:

    猜你喜欢
    • 2019-07-09
    • 1970-01-01
    • 2019-05-12
    • 1970-01-01
    • 2015-04-20
    • 2014-08-01
    • 2018-01-04
    • 2016-12-10
    • 2020-07-03
    相关资源
    最近更新 更多