Jenkins - Get code from BitBucket with SSH

夙愿已清 提交于 2020-01-06 20:01:42

问题


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.


回答1:


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.



来源:https://stackoverflow.com/questions/34420362/jenkins-get-code-from-bitbucket-with-ssh

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!