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

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-19 11:09:21  来源:igfitidea点击:

How to clone a BitBucket repository with Jenkins

gitjenkinsbitbucket

提问by Varun

I am using RedHat Linux

我正在使用 RedHat Linux

  1. I have created a repository in BitBucketsay Demoand I have some HTMLcode into that.
  2. I have installed Jenkinson my system.
  1. 我在BitBucketDemo 中创建了一个存储库,并且我有一些HTML代码。
  2. 我已经安装Jenkins在我的系统上。

What I am trying to do is clone the BitBucketrepository with Jenkinsso that I will be able to build the project.

我想要做的是克隆BitBucket存储库,Jenkins以便我能够构建项目。

Steps what I am following is

我正在遵循的步骤是

  1. Creating a new Job In Jenkins.
  2. Giving a description of the project
  3. In the Source Code Managementtab selecting gitand Jenkinsask for repository URL, and I am giving this URL. enter image description here
  1. Jenkins.
  2. 描述项目
  3. 源代码管理选项卡中选择gitJenkins询问存储库 URL,我提供了这个 URL。 在此处输入图片说明

but Jenkinsthrowing 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 BitBucketplug-in for Jenkinsthat 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 部分并添加正确的路径。

enter image description hereIts 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:

https://[email protected]/UserName/java-script.git

https://[email protected]/UserName/java-script.git

回答by Anu Raj

This is because private key is not establishing to GIT through Jenkins.

这是因为私钥不是通过 Jenkins 建立到 GIT 的。

So create credentials:

所以创建凭据:

  1. go to Jenkin Configure==>Source Code Management==>Add==>Jenkins;
  2. select Domain as global;
  3. select Kind 'SSH username with password';
  4. Copy the user name from id_rsa.pub file and paste it in username field;
  5. Copy the private key from id_rsa file and paste it in 'Private Key==> Enter directly'
  1. 转到詹金配置==>源代码管理==>添加==>詹金斯;
  2. 选择域为全局;
  3. 选择“带密码的 SSH 用户名”;
  4. 从 id_rsa.pub 文件中复制用户名并将其粘贴到用户名字段中;
  5. 从 id_rsa 文件中复制私钥并将其粘贴到“私钥==>直接输入”中

It should work, try it.

应该可以,试试吧。