CircleCI文件未同步到服务器

时间:2018-11-01 06:17:49

标签: circleci circleci-2.0

我是CircleCI的新手,我的配置如下。我正在尝试将文件同步到服务器。连接工作正常,但完成后没有文件复制到服务器。我的路径和rsync命令有什么问题吗?

version: 2
jobs:
  build:
    docker:
      - image: duanecilliers/alpine-composer-rsync:latest
    steps:
      - checkout
  deploy:
    machine:
      enabled: true
    steps:
      - add_ssh_keys:
          fingerprints:
          - "5e:3c:c3:58:9d:cf:fX:XX:XX:XX:XX:84:8a:b9:XX:XX"
      - run:
          name: Deploy Over SSH
          command: |
            rsync -e ssh -avvz --exclude=node_modules ~/project serverpilot@1XX.104.XX.XX:/srv/users/serverpilot/apps/XXXX/public/

workflows:
  version: 2
  build-and-deploy:
    jobs:
      - build
      - deploy:
          requires:
            - build
          filters:
            branches:
              only: master

我得到以下输出。

#!/bin/bash -eo pipefail
rsync -e ssh -avvz --exclude=node_modules ./ serverpilot@172.XXX.XX.XX:/srv/users/serverpilot/apps/xxx/public/
opening connection using: ssh -l serverpilot 172.XXX.XX.XX rsync --server -vvlogDtprze.iLs . /srv/users/serverpilot/apps/xxx/public/  (9 args)
Warning: Permanently added '172.XXX.XX.XX' (ECDSA) to the list of known hosts.

sending incremental file list
delta-transmission enabled
./
total: matches=0  hash_hits=0  false_alarms=0 data=0

sent 62 bytes  received 50 bytes  32.00 bytes/sec
total size is 0  speedup is 0.00

1 个答案:

答案 0 :(得分:0)

由于deploy作业没有任何文件,因此没有文件要复制到服务器。

build作业获取文件,但checkout步骤实际上是git clone。有几种方法可以将文件放入deploy作业中,但是在这种情况下,最好的选择是使用CircleCI Workspaces将文件从build作业复制到deploy作业