Jenkins - 使用SSH从BitBucket获取代码 [英] Jenkins - Get code from BitBucket with SSH

查看:997
本文介绍了Jenkins - 使用SSH从BitBucket获取代码的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我创建了一个私钥并将公钥添加到了我的密钥bitbucket上,就像 tutorial



我试图将私钥添加到Jenkins的Credentials菜单下,但它只是说:

 无法连接到存储库:CommandC:\ Program Files \Git\cmd\git.exe  - c core.askpass = true ls-remote -h git@bitbucket.org:bla / blabla.git HEAD返回状态码128:
stdout:
stderr:权限被拒绝(publickey)。
致命:无法从远程存储库读取。

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

我在做Jenkins错了什么?



感谢。

解决方案

我和詹金斯有类似的问题。然后在我的工作配置帮助中,我发现了这个


对于超级项目的远程URL,URL的结尾决定了是否假设裸露或非裸存储库:


  • 如果远程URL以/.git结尾,则假定为非裸存储库。



$远程URL不以/.git结尾b
$ b

现在我不知道为什么文档是/.git,但是这导致我尝试使用没有.git后缀的我的repo url,因为bitbucket中的repo是空的。



所以在你的情况下,我会尝试设置回购网址为:

  git @ bitbucket.org:bla/blabla 

注意.git已被删除。

I Created a private key and added the public key to my keys on bitbucket just like explained in this tutorial

I'm trying to add the private key to Jenkins under Credentials menu but it just keep saying:

Failed to connect to repository : Command "C:\Program Files\Git\cmd\git.exe -c core.askpass=true ls-remote -h git@bitbucket.org:bla/blabla.git HEAD" returned status code 128:
stdout: 
stderr: Permission denied (publickey). 
fatal: Could not read from remote repository.

Please make sure you have the correct access rights
and the repository exists.

What am i doing wrong withing Jenkins?

Thanks.

解决方案

I had a similar problem with Jenkins. Then in the configuration help of my job I spotted this

For a remote URL to a super-project, the ending of the URL determines whether a bare or non-bare repository is assumed:

  • If the remote URL ends with /.git, a non-bare repository is assumed.
  • If the remote URL does NOT end with /.git, a bare repository is assumed.

Now I'm not sure why the documentation the /.git but this led me to try my repo url without the .git suffix, since a repo in bitbucket is bare.

so in your case I would try setting the repo url to:

git@bitbucket.org:bla/blabla

Note the ".git" has been removed.

这篇关于Jenkins - 使用SSH从BitBucket获取代码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆