gitlab-runner 运行node打包命令失败

手动启动docker

node:10.15.3 将项目目录映射,可以正常打包

使用gitlab-runner 竟然失败,返回码为1

build:
  image: node:10.15.3
  stage: build

日志内容

0 info it worked if it ends with ok
1 verbose cli [ '/usr/local/bin/node', '/usr/local/bin/npm', 'run', 'build' ]
2 info using npm@6.4.1
3 info using node@v10.10.0
4 verbose run-script [ 'prebuild', 'build', 'postbuild' ]
5 info lifecycle web-test@0.1.0~prebuild: web-test@0.1.0
6 info lifecycle web-test@0.1.0~build: web-test@0.1.0
7 verbose lifecycle web-test@0.1.0~build: unsafe-perm in lifecycle true
8 verbose lifecycle web-test@0.1.0~build: PATH: /usr/local/lib/node_modules/npm/node_modules/npm-lifecycle/node-gyp-bin:/builds/web-front-end/test/node_modules/.bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
9 verbose lifecycle web-test@0.1.0~build: CWD: /builds/web-front-end/test
10 silly lifecycle web-test@0.1.0~build: Args: [ '-c', 'react-app-rewired build' ]
11 silly lifecycle web-test@0.1.0~build: Returned: code: 1  signal: null
12 info lifecycle web-test@0.1.0~build: Failed to exec build script
13 verbose stack Error: web-test@0.1.0 build: `react-app-rewired build`
13 verbose stack Exit status 1
13 verbose stack     at EventEmitter.<anonymous> (/usr/local/lib/node_modules/npm/node_modules/npm-lifecycle/index.js:301:16)
13 verbose stack     at EventEmitter.emit (events.js:182:13)
13 verbose stack     at ChildProcess.<anonymous> (/usr/local/lib/node_modules/npm/node_modules/npm-lifecycle/lib/spawn.js:55:14)
13 verbose stack     at ChildProcess.emit (events.js:182:13)
13 verbose stack     at maybeClose (internal/child_process.js:962:16)
13 verbose stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:251:5)
14 verbose pkgid web-test@0.1.0
15 verbose cwd /builds/web-front-end/test
16 verbose Linux 3.10.0-693.2.2.el7.x86_64
17 verbose argv "/usr/local/bin/node" "/usr/local/bin/npm" "run" "build"
18 verbose node v10.10.0
19 verbose npm  v6.4.1
20 error code ELIFECYCLE
21 error errno 1
22 error web-test@0.1.0 build: `react-app-rewired build`
22 error Exit status 1
23 error Failed at the web-test@0.1.0 build script.
23 error This is probably not a problem with npm. There is likely additional logging output above.
24 verbose exit [ 1, true ]
阅读 3.5k
1 个回答

找到问题了,process.env.CI=true gitlab-runner 默认将CI参数设置为true

variables:
  CI: false