Continuous integration Gitlab CI react脚本:未找到
我正在尝试为一个示例react项目构建一个简单的管道。 这是我的.gitlab-ci.yml文件Continuous integration Gitlab CI react脚本:未找到,continuous-integration,gitlab,devops,gitlab-ci,Continuous Integration,Gitlab,Devops,Gitlab Ci,我正在尝试为一个示例react项目构建一个简单的管道。 这是我的.gitlab-ci.yml文件 image: node:12 stages: - build - test build_react: stage: build script: - echo "Building deploy package" - yarn install - yarn build - echo "Build successful" artifacts:
image: node:12
stages:
- build
- test
build_react:
stage: build
script:
- echo "Building deploy package"
- yarn install
- yarn build
- echo "Build successful"
artifacts:
expire_in: 1 hour
paths:
- build
test_react:
stage: test
needs: [build_react]
script:
- echo "Testing project"
- yarn test --watchAll=false
- echo "Test successful"
构建通过了,但在测试阶段失败了
$ react-scripts test --watchAll=false
/bin/sh: 1: react-scripts: not found
问题似乎来自
构建反应:
命令warn install
将在节点模块
文件夹中安装依赖项(此文件夹不在存储库的提交文件中,因为它在.gitignore
中提到过)。
如果您需要其他依赖作业中的依赖项(test\u react
),则应将它们指定为cache
或artifacts
因此,build\u react
可能如下所示:
⋮
build_react:
stage: build
script:
- echo "Building deploy package"
- yarn install
- yarn build
- echo "Build successful"
artifacts:
expire_in: 1 hour
paths:
- build
- node_modules/ ### This will make the modules available to other dependent jobs
⋮
谢谢你的解释!让我一天都很愉快搜索了大约3天在这一个!谢谢