【问题标题】:Gitlab CI automatic deploy using rsync and sshpassGitlab CI 自动部署使用 rsync 和 sshpass
【发布时间】:2018-08-11 07:14:41
【问题描述】:

我在 gitlab-ci 上的自动部署有问题。我想将文件从 docker run on runner 发送到远程主机(我的站点托管)。 我的.gitlab-ci.yml是这样的

variables:
# STAGING CONFIGURATION
  STAGING_USER: "test@test.com"
  STAGING_URL: "test.com"
# $STAGING_SSH_PASSWORD - configure in gilab->settings->CI/CD->variables

# image with php an
image: webdevops/php-apache-dev:5.6

before_script:
  - apt-get update -qq && apt-get install -y -qq sshpass
  - apt-get install zip unzip
  - apt-get install -y ssh
  - mkdir ~/.ssh
  - echo "StrictHostKeyChecking no" >> ~/.ssh/config
  - apt-get install -y rsync

# DEPLOY STAGING
DEPLOY_STAGING:
  stage: deploy
  only:
    - master
  script:
    - export SSHPASS=$STAGING_SSH_PASSWORD
    - rsync -hrvz -e sshpass -e  theme/ $STAGING_USER:~/test/

但是当我尝试使用这个配置时,我得到了错误

rsync: Failed to exec theme/: Permission denied (13) rsync error: error in IPC code (code 14) at pipe.c(85) [Receiver=3.1.2] rsync: connection unexpectedly closed (0 bytes received so far) [Receiver] rsync error: error in rsync protocol data stream (code 12) at io.c(235) [Receiver=3.1.2] ERROR: Job failed: exit code 1

我不知道如何正确配置它。我必须通过 sshpass 进行身份验证,因为我的服务器不允许 rsa 身份验证。

【问题讨论】:

    标签: deployment rsync gitlab-ci sshpass


    【解决方案1】:

    在 sshpass 的手册页中,我找到了这个示例:

    rsync --rsh='sshpass -p 12345 ssh -l test' host.example.com:path . 
    

    https://linux.die.net/man/1/sshpass

    【讨论】:

      【解决方案2】:

      您需要将 rsync ssh shell 参数放在引号中:

      rsync -hrvz -e "sshpass -e" theme/ $STAGING_USER:~/test/
      

      【讨论】:

      • 感谢您的回答,但这对我不起作用。现在我收到这样的错误。 sshpass: invalid option -- 'l' protocol version mismatch -- is your shell clean? (see the rsync man page for an explanation) rsync error: protocol incompatibility (code 2) at compat.c(178) [sender=3.1.2]也许你对这个问题有其他想法?
      猜你喜欢
      • 2017-10-10
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-07-27
      • 2016-08-08
      • 2023-02-11
      • 2018-12-04
      • 2018-12-10
      相关资源
      最近更新 更多