git - 尝试使用 jenkins 克隆 git 存储库时出现错误 128
问题描述
我可以在托管 Jenkins 应用程序的 Linux 服务器上克隆我的 git 存储库,但是当我尝试创建一个新的 Jenkins 作业来执行此操作时,我收到错误 128。
“无法连接到存储库:命令“git ls-remote -h ssh://git@bitbucket.org/user/proj.git HEAD”返回状态码 128:标准输出:标准错误:权限被拒绝(公钥)。致命:可以不从远程存储库中读取。
请确保您拥有正确的访问权限并且存储库存在。”
我做过的事情
在 Linux 服务器上安装 git。
安装 BitBucket 插件及其对 Jenkins 应用程序的依赖项。
创建一个 SSH 密钥。
- 将密钥导入 BitBucket 和 Jenkins 文件夹。
- 在 SSH 密钥上设置 Jenkins 用户的权限。
- 我在 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
图片:
解决方案
在 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
)
推荐阅读
- flutter - 没有定义“statefulwidget.createstate”和 setstate 的具体实现
- tfs - devops feed 显示来自上游来源的包。我可以禁用它吗?
- python - 带有不等列的 Pandas DataFrame 将用 NA 填充
- c - 理解 Gtk 模板对象
- java - 带弹簧靴的 Hikari cp .. 活动连接始终为 1 .. 不增加但不降低到 0
- c++ - 编译“fopen_s”时出错未在此范围内声明
- ansible - 从引号列表中返回 IP 地址 - Ansible
- sql-server - 使用 Fluentmigrator 转换 SQL 表达式以创建索引
- graph - rrdtool图忽略--step?
- c# - 自定义对象作为肥皂服务的参数始终为空