我正在以下环境中运行:
GIT + Self hosted Gitlab
Node.js + Express
Mocha ( for tests )
Winston ( for logging)
命令:
./node_modules/.bin/mocha
在本地系统所有分支机构上都可以正常运行。但是在多个分支上的gitlab上同样失败(在其中一个分支上,它可以工作)。
我所有的node.js异常都进入了 logs / exceptions.log 文件。 在本地系统上,我可以查看exceptions.log的内容以找出问题所在,但是在Gitlab => PipeLines上,我无法查看此文件。
如果我可以在Gitlab上看到exceptions.log文件的内容,则可以找出问题所在
这是我的 .gitlab-ci 文件:
image: node:6
services:
- postgres:latest
variables:
POSTGRES_DB: test
POSTGRES_USER: nodeapp
POSTGRES_PASSWORD: ""
stages:
# Install necessary dependencies.
- build
# Run tests
- test
# Clean up dependencies if build fails.
- build_cleanup
cache:
key: XYZ_Cache_03_05_2018
paths:
- node_modules/
# Job: Build
# Checks & Installs dependencies.
build:
stage: build
script:
# check & install apt-get
- 'which apt-get || ( apt-get update )'
# check & install node
- 'which node || ( apt-get -y install nodejs --silent )'
# check & install npm
- 'which npm || ( apt-get -y install npm --silent )'
allow_failure: false
# Job: Test
# Run tests against our application
# If this fails, we do not deploy
test:
stage: test
script:
- npm install
- npm install -y --global bower --silent
- bower install --allow-root --silent
- npm install --global gulp-cli
- npm install mocha
- ./node_modules/mocha/bin/mocha
allow_failure: false
build_cleanup:
stage: build_cleanup
script:
- rm -rf node_modules
when: on_failure