2017-02-13 4 views
1

Ich habe gerade meine Gitlab-ci.yaml Datei mit drei Stufen konfiguriert bekam: - Test - bereitstellen - veröffentlichenGitlab CI: Build successful obwohl NPM Fehler

Manchmal treten NPM Fehler, wenn ich oder ein Entwickler vergisst --save ein Npm-Paket, die -test Bühne wird nicht ordnungsgemäß abgeschlossen, gibt aber immer noch "Build bestanden" zurück. Anschließend wird es blind bereitgestellt und veröffentlicht, da die Pipeline nicht abgebrochen wurde.

Wie kann ich NPM ERR machen! Stoppen Sie die aktuelle Phase und stoppen Sie den Rest des Laufens?

Ich habe dieses Problem simuliert, indem ich das Bluebird-Paket absichtlich weggelassen habe. Es beeinflusst die gesamte Prüfung/deploy/veröffentlichen Prozess und im Wesentlichen schlechten Code wurde eingesetzt und laufen auf meinem Server:

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 

Antwort

1

Sie haben gehören Sie nicht Travis-CI Config oder die Skripte, die Sie alles laufen, aber für Beispiel: Wenn Sie ein Skript haben:

#!/bin/sh 
npm install 
npm test 

dann kann das Skript immer noch erfolgreich beendet werden, auch wenn die Kommentare Fehler zurückgegeben haben. Was Sie tun können, ist:

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

um sicherzustellen, dass das Skript selbst den Fehler an das Betriebssystem zurückgibt. Dies ist ein allgemeiner Rat, der nicht für GitLab spezifisch ist, aber ich kann nichts Genaueres posten, ohne Ihre Konfiguration und Ihre Skripte zu sehen.