scp не может найти текущий каталог во время работы Gitlab CI - PullRequest
0 голосов
/ 04 октября 2019

Я использую Gitlab CI для сборки и развертывания на сервере. Все работает хорошо, за исключением самого конца, когда я хочу скопировать встроенные файлы на мой сервер через scp.

. Вот это .gitlab-ci.yml

image: trion/ng-cli-karma

cache:
  paths:
    - node_modules/

before_script:
  - apt-get update -qq && apt-get install -y -qq sshpass

deploy_stage:
  stage: deploy
  environment: Staging
  only:
    - master
  script:
    - rm ./package-lock.json
    - npm install
    - npm run build-dev
    - cd dist/
    - ls
    - sshpass -V
    - export SSHPASS=$USER_PASS 
    - sshpass -e scp -o stricthostkeychecking=no -r . root@159.89.84.177:/var/www/html

.

Running with gitlab-runner 12.3.0 (a8a019e0)
  on docker-auto-scale ed2dce3a
Using Docker executor with image trion/ng-cli-karma ...
Pulling docker image trion/ng-cli-karma ...
Using docker image sha256:037ee824704dc86fa1b69cb50bc9445b0aa02c2fe7708462bdb2ca5584bde7bd for trion/ng-cli-karma ...
Running on runner-ed2dce3a-project-14638464-concurrent-0 via runner-ed2dce3a-srm-1570180837-5976d76d...
Fetching changes with git depth set to 50...
Initialized empty Git repository in /builds/Axiol/my-really-awesome-project/.git/
Created fresh repository.
From https://gitlab.com/Axiol/my-really-awesome-project
 * [new branch]      master     -> origin/master
Checking out f1cfb167 as master...

Skipping Git submodules setup
Checking cache for default...
Downloading cache.zip from https://storage.googleapis.com/gitlab-com-runners-cache/project/14638464/default 
Successfully extracted cache
$ apt-get update -qq && apt-get install -y -qq sshpass
debconf: delaying package configuration, since apt-utils is not installed
Selecting previously unselected package sshpass.
(Reading database ... 
(Reading database ... 5%
(Reading database ... 10%
(Reading database ... 15%
(Reading database ... 20%
(Reading database ... 25%
(Reading database ... 30%
(Reading database ... 35%
(Reading database ... 40%
(Reading database ... 45%
(Reading database ... 50%
(Reading database ... 55%
(Reading database ... 60%
(Reading database ... 65%
(Reading database ... 70%
(Reading database ... 75%
(Reading database ... 80%
(Reading database ... 85%
(Reading database ... 90%
(Reading database ... 95%
(Reading database ... 100%
(Reading database ... 26118 files and directories currently installed.)
Preparing to unpack .../sshpass_1.06-1_amd64.deb ...
Unpacking sshpass (1.06-1) ...
Setting up sshpass (1.06-1) ...
$ rm ./package-lock.json
$ npm install
npm WARN sass-loader@8.0.0 requires a peer of sass@^1.3.0 but none is installed. You must install peer dependencies yourself.
npm WARN sass-loader@8.0.0 requires a peer of fibers@>= 3.1.0 but none is installed. You must install peer dependencies yourself.
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@1.2.9 (node_modules/fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@1.2.9: wanted {"os":"darwin","arch":"any"} (current: {"os":"linux","arch":"x64"})

audited 5973 packages in 5.325s
found 0 vulnerabilities

$ npm run build-dev

> my-really-awesome-project@1.0.0 build-dev /builds/Axiol/my-really-awesome-project
> webpack -d --mode development

Hash: 2441bcfb3aef68b9ec4f
Version: webpack 4.41.0
Time: 633ms
Built at: 10/04/2019 9:22:44 AM
    Asset      Size  Chunks             Chunk Names
bundle.js  41.6 KiB    main  [emitted]  main
Entrypoint main = bundle.js
[./node_modules/css-loader/dist/cjs.js!./node_modules/sass-loader/dist/cjs.js!./src/reset.scss] 1.26 KiB {main} [built]
[./node_modules/css-loader/dist/cjs.js!./node_modules/sass-loader/dist/cjs.js!./src/styles.scss] 306 bytes {main} [built]
[./src/index.js] 76 bytes {main} [built]
[./src/reset.scss] 444 bytes {main} [built]
[./src/styles.scss] 445 bytes {main} [built]
    + 2 hidden modules
$ cd dist/
$ ls
bundle.js
img
index.html
$ sshpass -V
sshpass 1.06
(C) 2006-2011 Lingnu Open Source Consulting Ltd.
(C) 2015-2016 Shachar Shemesh
This program is free software, and can be distributed under the terms of the GPL
See the COPYING file for more information.

Using "assword" as the default password prompt indicator.
$ export SSHPASS=$USER_PASS
$ sshpass -e scp -o stricthostkeychecking=no -r . root@my.server:/var/www/html
Warning: Permanently added 'my.server' (ECDSA) to the list of known hosts.
scp: error: unexpected filename: .
ERROR: Job failed: exit code 1

Я действительно не понимаю, как . может быть неопределенным.

1 Ответ

0 голосов
/ 11 октября 2019

вместо. попробуйте использовать $ (pwd).

sshpass -e scp -o stricthostkeychecking=no -r $(pwd) root@159.89.84.177:/var/www/html
Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...