Tuesday, April 12, 2022

cache and artifact

 cache in pipeline,useful for external project dependencies like node_modules folder in nodejs.

artifacts is to share data between stages.


stages:
  - build
  - test

#global cache for all jobs
#cache:
#  key: ${CI_COMMIT_REF_SLUG}
#  paths:
#   - node_modules/

build-websites:
  stage: build
  image: node
  cache:
   key: ${CI_COMMIT_REF_SLUG}
   paths:
    - node_modules/
  script:
   - npm install
   - npm install -g gatsby-cli
   - gatsby build
  artifacts:
   paths:
    - ./public

test artifact:
 image: alpine
 stage: test
 script:
  - grep -q "Gatsby" ./public/index.html
  - grep "XXXXX" ./public/index.html

test artifact:
 image: alpine
 stage: test
 script:
  - npm install
  - npm insrall -g gatsby-cli
  - gatsby serve & # & is for background job
  - sleep 3
  - curl "http://localhost:9000" | tac | tac | grep -q "Gatsby"

No comments:

Post a Comment