Npm GitLab runner未携带节点_模块和缓存到下一个作业?

Npm GitLab runner未携带节点_模块和缓存到下一个作业?,npm,gitlab,node-modules,cypress,gitlab-ci-runner,Npm,Gitlab,Node Modules,Cypress,Gitlab Ci Runner,我有一个问题,我的e2e测试在GitLab中失败,但正常通过。我将问题缩小到节点_模块和cypress缓存没有转移到下一个作业。这就是为什么存在WARN Local package.json,但节点\u模块缺失,您是否打算安装错误出现,因为节点\u模块不存在 我认为缓存没有继续的原因是因为它被保存在一个运行程序上,但是如果下一个作业在另一个运行程序上,缓存将不在那里,最终将失败。我可以把所有东西都放在一个作业中,但是如果我要添加另一个作业来部署,那么我仍然会遇到同样的问题 这是我的gitlab-

我有一个问题,我的e2e测试在GitLab中失败,但正常通过。我将问题缩小到节点_模块和cypress缓存没有转移到下一个作业。这就是为什么存在
WARN Local package.json,但节点\u模块缺失,您是否打算安装
错误出现,因为节点\u模块不存在

我认为缓存没有继续的原因是因为它被保存在一个运行程序上,但是如果下一个作业在另一个运行程序上,缓存将不在那里,最终将失败。我可以把所有东西都放在一个作业中,但是如果我要添加另一个作业来部署,那么我仍然会遇到同样的问题

这是我的gitlab-ci.yml文件:

image: cypress/base:12.18.4

variables:
  NPM_REGISTRY: https://registry.npmjs.org/
  npm_config_cache: $CI_PROJECT_DIR/.npm
  CYPRESS_CACHE_FOLDER: $CI_PROJECT_DIR/cache/Cypress

stages:
  - build
  - test:unit
  - test:e2e
  - lint

cache:
  key: ${CI_COMMIT_REF_SLUG}
  paths:
    - cache/Cypress
    - node_modules/

build:
  stage: build
  script:
    # set the npm registry if different from the default
    - npm config set registry $NPM_REGISTRY
    - npm i
    - npx cypress verify

test:unit:
  stage: test:unit
  script:
    - npm run test:unit:coverage
  artifacts:
    paths:
      - tests/unit/out/coverage
    when: always
    expire_in: 1 hour

test:e2e:
  stage: test:e2e
  script:
    - npm run test:e2e:headless
  artifacts:
    paths:
      - tests/e2e/out/reports
      - tests/e2e/out/coverage
    when: always
    expire_in: 1 hour

lint:
  stage: lint
  script:
    - npm run lint
这是GitLab中的错误日志:

Restoring cache
00:01
Updating CA certificates...
Checking cache for fix-gitlab-pipeline...
No URL provided, cache will not be downloaded from shared cache server. Instead a local version of cache will be extracted. 
Successfully extracted cache
Executing "step_script" stage of the job script
00:01
$ npm run test:e2e:headless
> start-test serve:e2e 8089 'cypress run'
sh: 1: start-test: not found
npm ERR! code ELIFECYCLE
npm ERR! syscall spawn
npm ERR! file sh
npm ERR! errno ENOENT
npm ERR! rds@0.1.0 test:e2e:headless: `start-test serve:e2e 8089 'cypress run'`
npm ERR! spawn ENOENT
npm ERR! 
npm ERR! Failed at the test@0.1.0 test:e2e:headless script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm WARN Local package.json exists, but node_modules missing, did you mean to install?
npm ERR! A complete log of this run can be found in:
npm ERR!     /builds/test/.npm/_logs/2021-01-05T17_16_55_957Z-debug.log
Uploading artifacts for failed job
00:00
Updating CA certificates...
WARNING: ca-certificates.crt does not contain exactly one certificate or CRL: skipping
WARNING: ca-cert-ca.pem does not contain exactly one certificate or CRL: skipping
Uploading artifacts...
WARNING: tests/e2e/out/reports: no matching files  
WARNING: tests/e2e/out/coverage: no matching files 
ERROR: No files to upload                          
ERROR: Job failed: exit code 1

我在这里回答了一个类似的问题:

要点是,默认情况下,每个运行程序将缓存项存储在该运行程序的文件系统上,因此其他运行程序将无法访问它。如果您的跑步者可以连接到共享文件系统,或者您可以使用S3(或GC或Azure的等效版本)或实现这些API的任何东西,那么您可以配置它存储的路径。我们使用Minio(),它实现了s3api


gitlab和Minio的文档在链接答案中。

我在这里回答了一个类似的问题:

要点是,默认情况下,每个运行程序将缓存项存储在该运行程序的文件系统上,因此其他运行程序将无法访问它。如果您的跑步者可以连接到共享文件系统,或者您可以使用S3(或GC或Azure的等效版本)或实现这些API的任何东西,那么您可以配置它存储的路径。我们使用Minio(),它实现了s3api

gitlab和Minio的文档在链接答案中