【发布时间】:2018-07-05 17:23:38
【问题描述】:
我已将我的 CI 管道配置为通过 SSH 远程连接到服务器,并使用最新更改更新那里的 git 存储库。然而它失败了。因为当 CI 运行git pull 命令时,响应是:“could not read Username for 'https://gitlab.com'”
我的问题是:有没有办法运行 git pull,在一个命令中包含用户名和密码?
我知道最好的方法是将 SSH 密钥添加到 gitlab 变量中以避免询问用户名和密码,但这对我也不起作用。所以我唯一的选择是提供用户名和密码。
我的 gitlab-ci.yml 文件如下:
deploy_staging:
stage: deploy
before_script:
- mkdir -p ~/.ssh
- echo -e "$DEPLOY_KEY" > ~/.ssh/id_rsa
- chmod 600 ~/.ssh/id_rsa
- '[[ -f /.dockerenv ]] && echo -e "Host *\n\tStrictHostKeyChecking no\n\n" > ~/.ssh/config'
script:
- ssh ubuntu@example.com "
cd my_Project &&
git pull
"
【问题讨论】:
-
试试
ssh-add ~/.ssh/id_rsa; ssh -A ubuntu@example.com "cd proj && git pull"。检查 - developer.github.com/v3/guides/using-ssh-agent-forwarding -
@HarishVed,我现在收到“无法打开与您的身份验证代理的连接”。错误。
-
检查这个 - stackoverflow.com/a/31835965/827715@Benjamin
标签: gitlab gitlab-ci gitlab-ci-runner