在 运行ning Cypress 之前,我如何在 Jenkins 中 运行 我的 React 应用程序?

How can I run my React Application in Jenkins before running Cypress?

为了在 Jenkins 中 运行 Cypress,我必须先 运行 我的 React 应用程序。

但是当 Jenkins 运行连接 React 应用程序时,它会抛出以下错误:

Error from chokidar (/data/node_modules/@babel/runtime/regenerator): Error: ENOSPC: System limit for number of file watchers reached, watch '/data/node_modules/@babel/runtime/regenerator'

来自 chokidar 的错误 (/data/node_modules/@emotion/unitless/dist):错误:ENOSPC:已达到文件观察者数量的系统限制,观察 '/data/node_modules/@emotion/unitless/dist ' 来自 chokidar 的错误(/data/node_modules/@pmmmwh/react-refresh-webpack-plugin/lib/runtime):错误:ENOSPC:达到文件观察者数量的系统限制,观察'/data/node_modules/@pmmmwh/react-refresh-webpack-plugin/lib/runtime' 来自 chokidar 的错误(/data/node_modules/@react-pdf/layout/lib/canvas):错误:ENOSPC:达到文件观察者数量的系统限制,观察'/data/node_modules/@react-pdf/layout/lib/canvas' 来自 chokidar 的错误(/data/node_modules/@react-pdf/layout/lib/page):错误:ENOSPC:达到文件观察者数量的系统限制,观察'/data/node_modules/@react-pdf/layout/lib/page' 来自 chokidar 的错误(/data/node_modules/@react-pdf/layout/lib/utils):错误:ENOSPC:达到文件观察者数量的系统限制,观察'/data/node_modules/@react-pdf/layout/lib/utils' 来自 chokidar 的错误(/data/node_modules/@react-pdf/render/lib):错误:ENOSPC:达到文件观察者数量的系统限制,观察'/data/node_modules/@react-pdf/render/lib' 来自 chokidar 的错误(/data/node_modules/@react-pdf/render/lib/utils):错误:ENOSPC:达到文件观察者数量的系统限制,观察'/data/node_modules/@react-pdf/render/lib/utils' 来自 chokidar 的错误(/data/node_modules/@react-pdf/stylesheet/lib):错误:ENOSPC:达到文件观察者数量的系统限制,观察'/data/node_modules/@react-pdf/stylesheet/lib'

所以一直无法运行Jenkins中的App。

这是抛出错误的 Jenkins 文件中的阶段:

stage('Cypress') {      
  steps {        
    configFileProvider([configFile(fileId: 'shell-aliases', variable: 'CFG_SHELL_ALIASES')]) {  
      sh '''
      source $CFG_SHELL_ALIASES > /dev/null 2>&1
      npm run start:e2e-ci          
      '''
    }    
  }
}    

这是 package.json 文件中的脚本,它是 运行ning:

"start:e2e-ci": "REACT_APP_TEST_ENV=e2e HTTPS=true HOST=pressboxlivelocal.statsperform.com PORT=443 react-scripts start"

也尝试将此环境 CHOKIDAR_USEPOLLING=1 添加到您的 start:e2e:-ci 脚本中