git 如何使用 Jenkins 克隆 BitBucket 存储库
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/31044777/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How to clone a BitBucket repository with Jenkins
提问by Varun
I am using RedHat Linux
我正在使用 RedHat Linux
- I have created a repository in
BitBucket
say Demoand I have someHTML
code into that. - I have installed
Jenkins
on my system.
- 我在
BitBucket
说Demo 中创建了一个存储库,并且我有一些HTML
代码。 - 我已经安装
Jenkins
在我的系统上。
What I am trying to do is clone the BitBucket
repository with Jenkins
so that I will be able to build the project.
我想要做的是克隆BitBucket
存储库,Jenkins
以便我能够构建项目。
Steps what I am following is
我正在遵循的步骤是
- Creating a new Job In
Jenkins
. - Giving a description of the project
- In the Source Code Managementtab selecting
git
andJenkins
ask for repository URL, and I am giving this URL.
- 在
Jenkins
. - 描述项目
- 在源代码管理选项卡中选择
git
并Jenkins
询问存储库 URL,我提供了这个 URL。
but Jenkins
throwing an error saying:
但Jenkins
抛出一个错误说:
Failed to connect to repository : Error performing command: git ls-remote -h git clone https://[email protected]/UserName/java-script.gitHEAD
无法连接到存储库:执行命令时出错:git ls-remote -h git clone https://[email protected]/UserName/java-script.gitHEAD
I spent around 3 days and could not configure this instead learned a lot about Jenkins
.
I have also tried the BitBucket
plug-in for Jenkins
that also was not working.
我花了大约 3 天的时间,无法配置它,而是学到了很多关于Jenkins
. 我也试过这个BitBucket
插件Jenkins
也没有用。
采纳答案by Abhijeet Kamble
For Jenkins 1.5 or greater( till 1.6)
对于 Jenkins 1.5 或更高版本(直到 1.6)
The error you are getting because in the global configuration of Jenkins, the git path is not correct/or not inserted.
您收到的错误是因为在 Jenkins 的全局配置中,git 路径不正确/或未插入。
That's why Jenkins is unable to run the git command.
这就是 Jenkins 无法运行 git 命令的原因。
Please go to Manage Jenkins-> Configure System Settings
. Check for git section and add correct path.
请前往Manage Jenkins-> Configure System Settings
。检查 git 部分并添加正确的路径。
Its already seems that you have removed the Git Clone from the URL provided by Bitbucket.
您似乎已经从 Bitbucket 提供的 URL 中删除了 Git Clone。
Update:
更新:
For Jenkins 2.0 or above
对于 Jenkins 2.0 或更高版本
You can find this setting under Global tool configuration.
您可以在全局工具配置下找到此设置。
回答by Bruno Lavit
Remove the "git clone" keywords and it should work :)
删除“git clone”关键字,它应该可以工作:)
Jenkins only need the http URL:
Jenkins 只需要 http URL:
回答by Anu Raj
This is because private key is not establishing to GIT through Jenkins.
这是因为私钥不是通过 Jenkins 建立到 GIT 的。
So create credentials:
所以创建凭据:
- go to Jenkin Configure==>Source Code Management==>Add==>Jenkins;
- select Domain as global;
- select Kind 'SSH username with password';
- Copy the user name from id_rsa.pub file and paste it in username field;
- Copy the private key from id_rsa file and paste it in 'Private Key==> Enter directly'
- 转到詹金配置==>源代码管理==>添加==>詹金斯;
- 选择域为全局;
- 选择“带密码的 SSH 用户名”;
- 从 id_rsa.pub 文件中复制用户名并将其粘贴到用户名字段中;
- 从 id_rsa 文件中复制私钥并将其粘贴到“私钥==>直接输入”中
It should work, try it.
应该可以,试试吧。