2017-02-13 4 views
1

В настоящее время я получил мой gitlab-ci.yaml файл настроен три этапа: - тест - развернуть - публиковатьGitlab CI: Построить успешным, хотя NPM ошибка

Иногда возникает НАЯ ошибка, если я или разработчик забывает о --save пакете npm, этап -test не выполняется должным образом, но все же возвращает «build received». Затем он перейдет к развертыванию и публикации вслепую, поскольку конвейер не был отменен.

Как я могу сделать ERM ERR! остановить текущую сцену и остановить остальную работу?

Я смоделировал эту проблему, намеренно опуская пакет bluebird. Это повлияло на весь тест/развернуть/опубликовать процесс и, по сути плохой код был развернут и работает на моем сервере:

myClass.js 
    .selectSpecificXYZ() 
     1) Should return an object containing SUCCESS 
     2) should return an object regardless of the input 
     3) should return an object with count 0 
     4) should return an ABC error 
     5) should return a DEF error 

    Array 
    #indexOf() 
     ✓ should return -1 when the value is not present 


    1 passing (87ms) 
    5 failing 

    1) myClass.js .selectSpecificXYZ() Should return an object containing SUCCESS when a correct myClass reference is passed: 
    Error: Cannot find module 'bluebird' 
     at require (internal/module.js:20:19) 
     at Object.<anonymous> (api_system/functions/helpers/database_wrappers.js:5:15) 
     at require (internal/module.js:20:19) 
     at Object.selectXYZByReference (api_system/functions/myClass/myClass.js:55:37) 
     at Context.it (api_system/test/myClass/myClassTests.js:19:32) 

    2) myClass.js .selectSpecificXYZ() should return an object regardless of the input (to handle success or error): 
    Error: Cannot find module 'bluebird' 
     at require (internal/module.js:20:19) 
     at Object.<anonymous> (api_system/functions/helpers/database_wrappers.js:5:15) 
     at require (internal/module.js:20:19) 
     at Object.selectXYZByReference (api_system/functions/myClass/myClass.js:55:37) 
     at Context.it (api_system/test/myClass/myClassTests.js:23:32) 

    3) myClass.js .selectSpecificXYZ() should return an object with count 0 as there's no value: 
    Error: Cannot find module 'bluebird' 
     at require (internal/module.js:20:19) 
     at Object.<anonymous> (api_system/functions/helpers/database_wrappers.js:5:15) 
     at require (internal/module.js:20:19) 
     at Object.selectXYZByReference (api_system/functions/myClass/myClass.js:55:37) 
     at Context.it (api_system/test/myClass/myClassTests.js:27:30) 

    4) myClass.js .selectSpecificXYZ() should return an Invalid Parameter error : 
    AssertionError: expected [Function] to throw error including 'Invalid Parameter' but got 'Cannot find module \'bluebird\'' 
     at Context.it (api_system/test/myClass/myClassTests.js:33:73) 

    5) myClass.js .selectSpecificXYZ() should return an Parameter Too Short error: 
    AssertionError: expected [Function] to throw error including 'Parameter Too Short' but got 'Cannot find module \'bluebird\'' 
     at Context.it (api_system/test/myClass/myClassTests.js:38:79) 




npm ERR! Linux 4.4.34-v7+ 
npm ERR! argv "/usr/local/bin/node" "/usr/local/bin/npm" "run" "test" "-recursive" 
npm ERR! node v7.2.1 
npm ERR! npm v3.10.10 
npm ERR! code ELIFECYCLE 
npm ERR! [email protected] test: `mocha api_system/test --recursive` 
npm ERR! Exit status 5 
npm ERR! 
npm ERR! Failed at the [email protected] test script 'mocha api_system/test --recursive'. 
npm ERR! Make sure you have the latest version of node.js and npm installed. 
npm ERR! If you do, this is most likely a problem with the myServer package, 
npm ERR! not with npm itself. 
npm ERR! Tell the author that this fails on your system: 
npm ERR!  mocha api_system/test --recursive 
npm ERR! You can get information on how to open an issue for this project with: 
npm ERR!  npm bugs myServer 
npm ERR! Or if that isn't available, you can get their info via: 
npm ERR!  npm owner ls myServer 
npm ERR! There is likely additional logging output above. 

npm ERR! Please include the following file with any support request: 
npm ERR!  /var/www/ci-tests/myServer/npm-debug.log 
[32;1m$ cd ..[0;m 
[32;1m$ rm -rf myServer[0;m 
[32;1m$ cd ..[0;m 
[32;1m$ rm -rf ci-tests[0;m 
[32;1m$ EOF[0;m 
[32;1mBuild succeeded 
[0;m 

ответ

1

Вы не включили вас Travis-CI конфигурации или сценарии, которые вы должны выполнить все, но для Например, когда у вас есть сценарий: тогда скрипт может с успехом выйти с успехом, даже когда комментарии возвращают ошибки. Что вы можете сделать:

#!/bin/sh 
npm install \ 
&& npm test \ 
|| exit 1 

чтобы убедиться, что сам сценарий возвращает ошибку в ОС. Это общий совет, не относящийся к GitLab, но я не могу опубликовать ничего более конкретного, не видя вашу конфигурацию и ваши скрипты.

Смежные вопросы