首页 > 解决方案 > 尝试使用 jenkins 克隆 git 存储库时出现错误 128

问题描述

我可以在托管 Jenkins 应用程序的 Linux 服务器上克隆我的 git 存储库,但是当我尝试创建一个新的 Jenkins 作业来执行此操作时,我收到错误 128。

“无法连接到存储库:命令“git ls-remote -h ssh://git@bitbucket.org/user/proj.git HEAD”返回状态码 128:标准输出:标准错误:权限被拒绝(公钥)。致命:可以不从远程存储库中读取。

请确保您拥有正确的访问权限并且存储库存在。”

我做过的事情

  1. 在 Linux 服务器上安装 git。

  2. 安装 BitBucket 插件及其对 Jenkins 应用程序的依赖项。

  3. 创建一个 SSH 密钥。

  4. 将密钥导入 BitBucket 和 Jenkins 文件夹。
  5. 在 SSH 密钥上设置 Jenkins 用户的权限。
  6. 我在 Jenkins 应用程序上创建了 SSH 凭据。

在终端上工作

bash-4.2$ bash-4.2$ whoami jenkins bash-4.2$ ssh -T git@bitbucket.org authenticated via a deploy key. You can use git or hg to connect to Bitbucket. Shell access is disabled. This deploy key has read access to the following repositories: user/proj: test3 -- jenkins@git . .

git -c core.askpass=true ls-remote -h ssh://git@bitbucket.org/user/proj.git [ec2-user@ip-172-31-31-13 ~]$ git -c core.askpass=true ls-remote -h ssh://git@bitbucket.org/user/proj.git db710fbf01f08789cf5c15e66269013f8e1543d4 refs/heads/master

图片:

1-linux 詹金斯版

2-ssh 2 git 使用默认用户

3-ssh 2 git 使用 jenkins 用户

4-ssh rsa 密钥

5-jenkins 身份验证密钥

6-詹金斯信用

7-jenkins 网页错误

标签: gitjenkinsbitbucketpermission-deniedpublic-key

解决方案


在 Jenkins 中配置它时,我会尝试编写 git 存储库的 URL,git@[...]而不是ssh://git@[...]

另一方面,您作为test3( ssh-rsa AAA[...]) 的私钥引入的密钥似乎不是私钥。它看起来像公钥。私钥是一个以 开头-----BEGIN RSA PRIVATE KEY-----和结尾的块-----END RSA PRIVATE KEY-----。在您的情况下,我认为它存储在名为的文件中jenkins_bitbucket_access(公钥存储在jenkins_bitbucket_access.pub


推荐阅读