git 从 jenkins 服务器连接到 bitbucket 存储库

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/20203565/
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-10 17:22:27  来源:igfitidea点击:

Connecting to bitbucket repository from jenkins server

gitsshjenkinsbitbucket

提问by bgarcial

At moment I'm trying to create connection from jenkins to my bitbucket repository, using the git plugin that I've installed in jenkins.

目前,我正在尝试使用我在 jenkins 中安装的 git 插件创建从 jenkins 到我的 bitbucket 存储库的连接。

When I enter to the repository URL, I get the following message notification shown in the figure:

当我输入到存储库 URL 时,我收到如下图所示的消息通知:

"Failed to connect to repository : Command "ls-remote -h [email protected]:safe2school-ondemand/s2s-android-padres.git HEAD" returned status code 128: stdout: stderr: Permission denied (publickey). fatal: The remote end hung up unexpectedly"

“无法连接到存储库:命令“ls-remote -h [email protected]:safe2school-ondemand/s2s-android-padres.git HEAD”返回状态代码 128:stdout:stderr:权限被拒绝(公钥)。致命:远端意外挂断”

Trying connect to bitbucket repo from jenkins through git

尝试通过 git 从 jenkins 连接到 bitbucket repo

I've install jenkins on apache tomcat container, which is located in a path /srv/apache-tomcat

我已经在 apache tomcat 容器上安装了 jenkins,它位于路径 /srv/apache-tomcat

In the system I have a root ssh-key and I add this key to bitbucket. I appreciate your support :)

在系统中,我有一个根 ssh 密钥,并将此密钥添加到 bitbucket。我感谢您的支持 :)

回答by geoom

You can try with user-password authentication credential, this is the alternative way that this plugin gives us.

您可以尝试使用用户密码身份验证凭据,这是该插件为我们提供的另一种方式。

  1. Click 'Add' button.
  1. 单击“添加”按钮。

enter image description here

在此处输入图片说明

  1. Select "User with password" in Kind input.
  2. Add bitbucket account credential.
  1. 在种类输入中选择“有密码的用户”。
  2. 添加 bitbucket 帐户凭据。

enter image description here

在此处输入图片说明

  1. Enter bitbucket repo url using 'https' protocol.
  1. 使用“https”协议输入 bitbucket repo url。

enter image description here

在此处输入图片说明

Finally, the absence of errors (like red messages under repo url input) means that the process had success.

最后,没有错误(如 repo url 输入下的红色消息)意味着该过程成功。

回答by MichaelS

In addition to @geoom answer, 2FA users can use "app passwords" for the credentials

除了@geoom 回答,2FA 用户还可以使用“应用密码”作为凭据

App passwords are substitute passwords for a user account which you can use for scripts and integrating tools to avoid putting your real password into configuration files.

App passwords are designed to be used for a single purpose with limited permissions, so they don't require two-step verification (2SV). This means app passwords can be used by users with 2SV make API calls to their Bitbucket account, and to integrate Bitbucket with other tools like Sourcetree and Bamboo.

应用程序密码是用户帐户的替代密码,您可以将其用于脚本和集成工具,以避免将您的真实密码放入配置文件中。

应用密码旨在用于具有有限权限的单一用途,因此它们不需要两步验证 (2SV)。这意味着具有 2SV 的用户可以使用应用密码对其 Bitbucket 帐户进行 API 调用,并将 Bitbucket 与其他工具(如 Sourcetree 和 Bamboo)集成。