0
votes

I try to build and push my react build folder with gitlab-ci.yml Build and test passes but deploy failed with this error : If I do the same script in my locale file, it works !

    lftp -e "mirror -R build/ ./test ; quit" -u $USERNAME,$PASSWORD $HOST
mirror: Access failed: /builds/myGitLab/myGitlabProjectName/build: No such file or directory
lftp: MirrorJob.cc:242: void MirrorJob::JobFinished(Job*): Assertion `transfer_count>0' failed.
/bin/bash: line 97:   275 Aborted                 (core dumped) lftp -e "mirror -R build/ ./test ; quit" -u $USERNAME,$PASSWORD $HOST
ERROR: Job failed: exit code 1

Here is my all yml file :

image: node:13.8

stages:
  - build
  - test
  - deploy

build:
  stage: build
  script:
    - npm install
    - npm run build

test:
  stage: test
  script:
    - yarn
    - yarn test

deploy:
  script:
    - apt-get update && apt-get install -y lftp
    - lftp -e "mirror -R build/ ./test ; quit" -u $USERNAME,$PASSWORD $HOST
    
enter code here
2

2 Answers

0
votes

I 've got it ! i was started from a docker image (node) to perform those 3 stages: the build, the test and the deploy but without success but i tried doing an ls-a in the stage deploy I realized that I didn't have the build folder. Because the docker image was recreated each time, so I added artifacts to keep the buid file! Once the job in the build stage is "done".it keep in a variable buid readable for next job also the deploy !

image: node:13.8

stages:
  - build
  - test
  - deploy

build:
  stage: build
  script:
    - npm install
    - npm run build
  only:
    - master
  artifacts:
    paths:
      - build

test:
  stage: test
  script:
    - yarn
    - yarn test

deploy:
  stage: deploy
  before_script:
    - apt-get update -qq
  script:
    - apt-get install -y -qq lftp
    - ls -a
    - lftp -e "set ssl:verify-certificate false; mirror --reverse --verbose --delete build/ ./test2 ; quit" -u $USERNAME,$PASSWORD $HOST
  only:
    - master

-1
votes

I have a part of the answer, but i would like to do something better Actually, i understood what is going on. On every stage the docker image build then after the build on the test and deploy, there is no more build folder. I don't know how to persit the docker image witch is node to every stages. Any help will be welcome. To make it works i have done every script in one stage this way: image: node:13.0.1

stages: - production

build: stage: production script: - npm install - npm run build - npm run test - apt-get update -qq && apt-get install -y -qq lftp - lftp -e "mirror -R build/ ./test ; quit" -u $USERNAME,$PASSWORD $HOST only: - master