【发布时间】:2019-06-07 10:33:38
【问题描述】:
我正在尝试通过 bitbucket 管道将我的应用程序自动部署到数字海洋。以下是我的部署步骤:
- 使用 ssh 连接到远程数字海洋水滴
- 通过使用 ssh 运行 git clone 来克隆我的存储库
- 使用 docker-compose 启动我的应用程序
我已成功设置对我的遥控器的 ssh 访问。我还配置了对我的存储库的 ssh 访问,并且可以从我的远程服务器成功执行 git clone。 但是,在管道中,当连接到远程服务器成功时, git clone 命令失败并出现以下错误。
git@bitbucket.org:权限被拒绝(公钥)。 致命:无法从远程存储库读取。
有人知道这里发生了什么吗?
这是我的bitbucket-pipelines.yml
image: atlassian/default-image:latest
pipelines:
default:
- step:
deployment: production
script:
- cat deploy.sh | ssh $USER_NAME@$HOST
- echo "Deploy step finished"
还有部署脚本deploy.sh
#!/usr/bin/env sh
git clone git@bitbucket.org:<username>/<my_repo>.git
cd my_repo
docker-compose up -d
git clone ssh 命令within the droplet 和from the pipeline 的日志
【问题讨论】:
-
Droplet 上的
git如何访问 SSH 密钥?尝试通过执行GIT_SSH_COMMAND='ssh -vvv' git clone ...之类的操作将详细日志记录添加到用于git clone的ssh,或者如果这不起作用(git 太旧)尝试其他建议之一here 和选项LogLevel DEBUG3。获得输出后,您可以将其放在 pastebin 并在此处提供链接。