Jenkins通过SSH访问专用BitBucket回购 [英] Jenkins access private BitBucket repo over SSH

查看:361
本文介绍了Jenkins通过SSH访问专用BitBucket回购的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我无法让Jenkins通过SSH克隆BitBucket上的git存储库。它失败,出现以下消息:

 在工作区/ var / lib / jenkins / workspace / test中构建
[ssh使用凭据git(git@bitbucket.org:< user> /< repo> .git)
[ssh-agent]寻找ssh-agent实现...
[ssh-代理] Java / JNR ssh-agent
[ssh-agent]开始。
签出:test / / var / lib / jenkins / workspace / test - hudson.remoting.LocalChannel@2b619bca
使用策略:默认
从1个远程Git存储库获取更改
提取上游从原点变化
错误:从原点/原点获取问题 - 可能无法使用。无论如何继续
hudson.plugins.git.GitException:命令git fetch -t origin + refs / heads / *:refs / remotes / origin / *返回状态码128:
stdout:
stderr:ssh:连接到主机bitbucket.org端口22:连接被拒绝
致命:远程端意外挂起



采取的步骤




  • 创建SSH密钥对

  • 添加公钥作为BitBucket存储库的部署密钥
  • 在Jenkins凭证管理器插件中安装SSH密钥和用户名(已尝试'git'和我的BB帐户名称)

  • 尝试使用

    git@bitbucket.org形式的URL来克隆构建中的存储库: < user> /< repo> .git




不使用凭证管理器并在 /var/log/jenkins/.ssh / 中手动安装密钥,但无济于事。



任何想法我在做什么作为@ user1562655的建议,克隆由于另一个问题而失败 - 在这种情况下,防火墙阻塞



解决的办法是使用端口443(因为服务器允许这样做)和一个不同的BitBucket URL:

  ssh://git@altssh.bitbucket.org:443 /< user> /< repo> .git 

...而不是

  ssh:/ /git@bitbucket.org:<user>/<repo>.git 

更多资讯该计划可在此处获得:



UsetheSSHprotocolwithBitbucket-SSHonPort443


I'm having trouble getting Jenkins to clone a git repository on BitBucket via SSH. It's failing with the following message:

Building in workspace /var/lib/jenkins/workspace/test
[ssh-agent] Using credentials git (git@bitbucket.org:<user>/<repo>.git)
[ssh-agent] Looking for ssh-agent implementation...
[ssh-agent]   Java/JNR ssh-agent
[ssh-agent] Started.
Checkout:test / /var/lib/jenkins/workspace/test - hudson.remoting.LocalChannel@2b619bca
Using strategy: Default
Fetching changes from 1 remote Git repository
Fetching upstream changes from origin
ERROR: Problem fetching from origin / origin - could be unavailable. Continuing anyway
hudson.plugins.git.GitException: Command "git fetch -t origin +refs/heads/*:refs/remotes/origin/*" returned status code 128:
stdout: 
stderr: ssh: connect to host bitbucket.org port 22: Connection refused
fatal: The remote end hung up unexpectedly

Steps taken

  • Create an SSH keypair
  • Add the public key as a deployment key for the repository on BitBucket
  • Install the SSH key and username (have tried both 'git' and my BB account name) in the Jenkins Credentials manager plugin
  • Attempt to clone the repository in the build using a URL in form of

    git@bitbucket.org:<user>/<repo>.git

I've also tried not using the credentials manager and manually installing the keys in /var/log/jenkins/.ssh/, but to no avail.

Any ideas what I'm doing wrong?

解决方案

As @user1562655 suggested out, the clone was failing due to another issue -- in this case the firewall was blocking outgoing ssh on port 22.

The fix was to use port 443 (as the server allows this), and a different BitBucket URL:

ssh://git@altssh.bitbucket.org:443/<user>/<repo>.git

…instead of

ssh://git@bitbucket.org:<user>/<repo>.git

More info on the scheme is available here:

UsetheSSHprotocolwithBitbucket-SSHonPort443

这篇关于Jenkins通过SSH访问专用BitBucket回购的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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