我无法让 Jenkins 通过 SSH 在 BitBucket 上克隆 git 存储库。它失败并显示以下消息:
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
采取的步骤
- 创建 SSH 密钥对
- 将公钥添加为 BitBucket 上存储库的部署密钥
- 在 Jenkins Credentials manager 插件中安装 SSH 密钥和用户名(已尝试过 'git' 和我的 BB 帐户名)
尝试使用以下形式的 URL 克隆构建中的存储库
git@bitbucket.org:<user>/<repo>.git
我也试过不使用凭证管理器并手动安装密钥/var/log/jenkins/.ssh/
,但无济于事。
任何想法我做错了什么?