Gitlab CD/CI: The user-provided path build/ does not exist

Viewed 4903

I have created one simple react for practicing gitlab's CI/CD pipeline. I have three jobs for CD/CI pipeline. First test the app then build then deploy to the AWS' S3 bucket. After successfully pass the test and run the build production, when it goes deploy stage I got this error : The user-provided path build does not exist. I don't know how to make path in Gitlab's cd/ci pipeline.

This is my gitlab's .gitlab-ci.yml file setup

image: 'node:12'
stages:
  - test
  - build
  - deploy

test:
  stage: test
  script:
    - yarn install
    - yarn run test

variables:
  AWS_ACCESS_KEY_ID: $AWS_ACCESS_KEY_ID
  AWS_SECRET_ACCESS_KEY: $AWS_SECRET_ACCESS_KEY
  AWS_REGION: $AWS_REGION
  S3_BUCKET_NAME: $S3_BUCKET_NAME

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

deploy:
  stage: deploy
  only:
    - master
  image: python:latest
  script:
     - pip install awscli
     - aws s3 cp build/ s3://$S3_BUCKET_NAME/ --recursive --include "*" 
1 Answers

If build/ folder is created as part of build stage then it should be passed as artefact to the deploy stage and deploy should reference build stage using dependencies:

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

deploy:
  stage: deploy
  only:
    - master
  image: python:latest
  dependencies:
    - build
  script:
     - pip install awscli
     - aws s3 cp build/ s3://$S3_BUCKET_NAME/ --recursive --include "*" 

Related