I installed Jenkins in a Linux server (I've not a docker container, just a regular server). I installed all suggested plugins in order to automate stuff for a Java and Angular applications.
Right now I've a problem running cypress tests. I can build Angular application, but I'm facing problems running cypress test in headless mode.
I created a "Freestyle project" (not a pipeline), just to run tests.
This is the relevant script section in my Angular project:
"scripts": {
"build": "ng build",
"start": "ng serve --port 3030",
"test": "start-server-and-test start http://localhost:3030 cy:run",
"cy:run": "cypress run",
"lint": "ng lint",
"e2e": "ng e2e"
},
As stated here, running the script test it should work and cypress should wait the application to be up and running.
When I run the Jenkins build, however, I've this error:
npm install
npm WARN deprecated [email protected]: You can find the new Popper v2 at @popperjs/core, this package is dedicated to the legacy v1
npm WARN deprecated [email protected]: request has been deprecated, see https://github.com/request/request/issues/3142
npm WARN deprecated [email protected]: Please see https://github.com/lydell/urix#deprecated
npm WARN deprecated [email protected]: https://github.com/lydell/resolve-url#deprecated
> [email protected] install /var/lib/jenkins/workspace/angular test/node_modules/websocket
> (node-gyp rebuild 2> builderror.log) || (exit 0)
make: Entering directory '/var/lib/jenkins/workspace/angular test/node_modules/websocket/build'
CXX(target) Release/obj.target/bufferutil/src/bufferutil.o
SOLINK_MODULE(target) Release/obj.target/bufferutil.node
COPY Release/bufferutil.node
CXX(target) Release/obj.target/validation/src/validation.o
SOLINK_MODULE(target) Release/obj.target/validation.node
COPY Release/validation.node
make: Leaving directory '/var/lib/jenkins/workspace/angular test/node_modules/websocket/build'
> [email protected] install /var/lib/jenkins/workspace/angular test/node_modules/node-sass
> node scripts/install.js
Cached binary found at /var/lib/jenkins/.npm/node-sass/4.13.1/linux-x64-72_binding.node
> [email protected] postinstall /var/lib/jenkins/workspace/angular test/node_modules/core-js
> node -e "try{require('./postinstall')}catch(e){}"
> @angular/[email protected] postinstall /var/lib/jenkins/workspace/angular test/node_modules/@angular/cli
> node ./bin/postinstall/script.js
> [email protected] postinstall /var/lib/jenkins/workspace/angular test/node_modules/cypress
> node index.js --exec install
Cypress 4.3.0 is installed in /var/lib/jenkins/.cache/Cypress/4.3.0
> [email protected] postinstall /var/lib/jenkins/workspace/angular test/node_modules/ngx-infinite-scroll
> opencollective-postinstall || exit 0
[96m[1mThank you for using ngx-infinite-scroll![96m[1m
[0m[96mIf you rely on this package, please consider supporting our open collective:[22m[39m
> [94mhttps://opencollective.com/ngx-infinite-scroll/donate[0m
> [email protected] postinstall /var/lib/jenkins/workspace/angular test/node_modules/node-sass
> node scripts/build.js
Binary found at /var/lib/jenkins/workspace/angular test/node_modules/node-sass/vendor/linux-x64-72/binding.node
Testing binary
Binary is fine
npm notice created a lockfile as package-lock.json. You should commit this file.
added 1799 packages from 1690 contributors and audited 20778 packages in 73.931s
51 packages are looking for funding
run `npm fund` for details
found 3 low severity vulnerabilities
run `npm audit fix` to fix them, or `npm audit` for details
+ npm run test
> [email protected] test /var/lib/jenkins/workspace/angular test
> start-server-and-test start http://localhost:3030 cy:run
starting server using command "npm run start"
and when url "[ 'http://localhost:3030' ]" is responding with HTTP status code 200
running tests using command "npm run cy:run"
> [email protected] start /var/lib/jenkins/workspace/angular test
> ng serve --port 3030
WARNING: This is a simple server for use in testing or debugging Angular applications
locally. It hasn't been reviewed for security issues.
Binding this server to an open connection can result in compromising your application or
computer. Using a different host than the one passed to the "--host" flag might result in
websocket connection issues. You might need to use "--disableHostCheck" if that's the
case.
Compiling @angular/core : es2015 as esm2015
Compiling @angular/common : es2015 as esm2015
Compiling @angular/animations : es2015 as esm2015
Compiling @angular/forms : es2015 as esm2015
Compiling @angular/cdk/platform : es2015 as esm2015
Compiling @angular/cdk/bidi : es2015 as esm2015
Compiling @angular/platform-browser : es2015 as esm2015
Compiling @angular/router : es2015 as esm2015
Compiling primeng/dom : es2015 as esm2015
Compiling primeng/api : es2015 as esm2015
Compiling @angular/animations/browser : es2015 as esm2015
Compiling @angular/cdk/keycodes : es2015 as esm2015
Compiling @angular/cdk/observers : es2015 as esm2015
Compiling @angular/cdk/a11y : es2015 as esm2015
Compiling @angular/platform-browser/animations : es2015 as esm2015
Compiling @angular/material/core : es2015 as esm2015
Compiling @angular/cdk/collections : es2015 as esm2015
Compiling @angular/cdk/scrolling : es2015 as esm2015
Compiling @angular/cdk/portal : es2015 as esm2015
Compiling primeng/utils : es2015 as esm2015
Compiling @angular/common/http : es2015 as esm2015
Compiling @angular/cdk/overlay : es2015 as esm2015
Compiling primeng/button : es2015 as esm2015
Compiling @angular/material/form-field : es2015 as esm2015
Compiling primeng/tooltip : es2015 as esm2015
Compiling @angular/material/button : es2015 as esm2015
Compiling @angular/cdk/layout : es2015 as esm2015
Compiling primeng/inputtext : es2015 as esm2015
Compiling primeng/dropdown : es2015 as esm2015
Compiling @angular/common : es2015 as esm2015
Compiling primeng/paginator : es2015 as esm2015
Compiling @angular/cdk/text-field : es2015 as esm2015
Compiling @angular/platform-browser-dynamic : es2015 as esm2015
Compiling @angular/material/input : es2015 as esm2015
Compiling @angular/material/icon : es2015 as esm2015
Compiling @angular/material/select : es2015 as esm2015
Compiling @angular/material/tooltip : es2015 as esm2015
Compiling @angular/core/testing : es2015 as esm2015
Compiling @angular/platform-browser/testing : es2015 as esm2015
Compiling @angular/compiler/testing : es2015 as esm2015
Compiling primeng/focustrap : es2015 as esm2015
Compiling primeng/messages : es2015 as esm2015
Compiling primeng/progressbar : es2015 as esm2015
Compiling @angular/material/dialog : es2015 as esm2015
Compiling @angular/cdk/accordion : es2015 as esm2015
Compiling @angular/material/divider : es2015 as esm2015
Compiling @angular/cdk/stepper : es2015 as esm2015
Compiling @angular/cdk/table : es2015 as esm2015
Compiling @angular/material/paginator : es2015 as esm2015
Compiling @angular/material/sort : es2015 as esm2015
Compiling @angular/cdk/tree : es2015 as esm2015
Compiling @angular/platform-browser-dynamic/testing : es2015 as esm2015
Compiling @angular/platform-server : es2015 as esm2015
Compiling @angular/common/testing : es2015 as esm2015
Compiling @ngx-translate/core : es2015 as esm2015
Compiling @angular/common/http : es2015 as esm2015
Compiling ngx-highlightjs : es2015 as esm2015
Compiling primeng/accordion : es2015 as esm2015
Compiling primeng/autocomplete : es2015 as esm2015
Compiling primeng/blockui : es2015 as esm2015
Compiling primeng/breadcrumb : es2015 as esm2015
Compiling primeng/calendar : es2015 as esm2015
Compiling primeng/captcha : es2015 as esm2015
Compiling primeng/card : es2015 as esm2015
Compiling primeng/carousel : es2015 as esm2015
Compiling primeng/chart : es2015 as esm2015
Compiling primeng/checkbox : es2015 as esm2015
Compiling primeng/chips : es2015 as esm2015
Compiling primeng/codehighlighter : es2015 as esm2015
Compiling primeng/colorpicker : es2015 as esm2015
Compiling primeng/confirmdialog : es2015 as esm2015
Compiling primeng/contextmenu : es2015 as esm2015
Compiling primeng/dataview : es2015 as esm2015
Compiling primeng/defer : es2015 as esm2015
Compiling primeng/dialog : es2015 as esm2015
Compiling primeng/dragdrop : es2015 as esm2015
Compiling primeng/dynamicdialog : es2015 as esm2015
Compiling primeng/editor : es2015 as esm2015
Compiling primeng/fieldset : es2015 as esm2015
Compiling primeng/fileupload : es2015 as esm2015
Compiling primeng/fullcalendar : es2015 as esm2015
Compiling primeng/galleria : es2015 as esm2015
Compiling primeng/gmap : es2015 as esm2015
Compiling primeng/inplace : es2015 as esm2015
Compiling primeng/inputmask : es2015 as esm2015
Compiling primeng/inputswitch : es2015 as esm2015
Compiling primeng/inputtextarea : es2015 as esm2015
Compiling primeng/keyfilter : es2015 as esm2015
Compiling primeng/lightbox : es2015 as esm2015
Compiling primeng/listbox : es2015 as esm2015
Compiling primeng/megamenu : es2015 as esm2015
Compiling primeng/menu : es2015 as esm2015
Compiling primeng/menubar : es2015 as esm2015
Compiling primeng/message : es2015 as esm2015
Compiling primeng/multiselect : es2015 as esm2015
Compiling primeng/orderlist : es2015 as esm2015
Compiling primeng/organizationchart : es2015 as esm2015
Compiling primeng/overlaypanel : es2015 as esm2015
Compiling primeng/panel : es2015 as esm2015
Compiling primeng/panelmenu : es2015 as esm2015
Compiling primeng/password : es2015 as esm2015
Compiling primeng/picklist : es2015 as esm2015
Compiling primeng/progressspinner : es2015 as esm2015
Compiling primeng/radiobutton : es2015 as esm2015
Compiling primeng/rating : es2015 as esm2015
Compiling primeng/scrollpanel : es2015 as esm2015
Compiling primeng/selectbutton : es2015 as esm2015
Compiling primeng/sidebar : es2015 as esm2015
Compiling primeng/slidemenu : es2015 as esm2015
Compiling primeng/slider : es2015 as esm2015
Compiling primeng/spinner : es2015 as esm2015
Compiling primeng/splitbutton : es2015 as esm2015
Compiling primeng/steps : es2015 as esm2015
Compiling primeng/table : es2015 as esm2015
Compiling primeng/tabmenu : es2015 as esm2015
Compiling primeng/tabview : es2015 as esm2015
Compiling primeng/terminal : es2015 as esm2015
Compiling primeng/tieredmenu : es2015 as esm2015
Compiling primeng/toast : es2015 as esm2015
Compiling primeng/togglebutton : es2015 as esm2015
Compiling primeng/toolbar : es2015 as esm2015
Compiling primeng/tree : es2015 as esm2015
Compiling primeng/treetable : es2015 as esm2015
Compiling primeng/tristatecheckbox : es2015 as esm2015
Compiling primeng/virtualscroller : es2015 as esm2015
Compiling @angular/animations/browser/testing : es2015 as esm2015
Compiling @angular/cdk/clipboard : es2015 as esm2015
Compiling @angular/cdk/drag-drop : es2015 as esm2015
Compiling @angular/common/http/testing : es2015 as esm2015
Compiling @angular/material/autocomplete : es2015 as esm2015
Compiling @angular/material/badge : es2015 as esm2015
Compiling @angular/material/bottom-sheet : es2015 as esm2015
Compiling @angular/material/button-toggle : es2015 as esm2015
Compiling @angular/material/card : es2015 as esm2015
Compiling @angular/material/checkbox : es2015 as esm2015
Compiling @angular/material/chips : es2015 as esm2015
Compiling @angular/material/datepicker : es2015 as esm2015
Compiling @angular/material/expansion : es2015 as esm2015
Compiling @angular/material/grid-list : es2015 as esm2015
Compiling @angular/material/icon/testing : es2015 as esm2015
Compiling @angular/material/list : es2015 as esm2015
Compiling @angular/material/menu : es2015 as esm2015
Compiling @angular/material/progress-bar : es2015 as esm2015
Compiling @angular/material/progress-spinner : es2015 as esm2015
Compiling @angular/material/radio : es2015 as esm2015
Compiling @angular/material/sidenav : es2015 as esm2015
Compiling @angular/material/slide-toggle : es2015 as esm2015
Compiling @angular/material/slider : es2015 as esm2015
Compiling @angular/material/snack-bar : es2015 as esm2015
Compiling @angular/material/stepper : es2015 as esm2015
Compiling @angular/material/table : es2015 as esm2015
Compiling @angular/material/tabs : es2015 as esm2015
Compiling @angular/material/toolbar : es2015 as esm2015
Compiling @angular/material/tree : es2015 as esm2015
Compiling @angular/material-moment-adapter : es2015 as esm2015
Compiling @angular/platform-server/testing : es2015 as esm2015
Compiling @angular/router/testing : es2015 as esm2015
Compiling @angular/service-worker : es2015 as esm2015
Compiling @angular/service-worker/config : es2015 as esm2015
Compiling @auth0/angular-jwt : module as esm5
Compiling @fullcalendar/angular : es2015 as esm2015
Compiling @ngx-translate/http-loader : es2015 as esm2015
Compiling angularx-qrcode : es2015 as esm2015
Compiling @angular/common/http/testing : es2015 as esm2015
Compiling @angular/common/testing : es2015 as esm2015
Compiling material-community-components : es2015 as esm2015
Compiling ng-lazyload-image : es2015 as esm2015
Compiling ng2-ckeditor : es2015 as esm2015
Compiling ng2-tel-input : es2015 as esm2015
Compiling ngx-barcode6 : es2015 as esm2015
Compiling ngx-cookie-service : es2015 as esm2015
Compiling ngx-daterangepicker-material : es2015 as esm2015
Compiling ngx-device-detector : es2015 as esm2015
Compiling ngx-highlightjs/plus : es2015 as esm2015
Compiling ngx-image-zoom : es2015 as esm2015
Compiling ngx-infinite-scroll : es2015 as esm2015
Compiling ngx-loading : es2015 as esm2015
Compiling primeng : es2015 as esm2015
Error: Timeout
at MergeMapSubscriber.project (/var/lib/jenkins/workspace/angular test/node_modules/wait-on/lib/wait-on.js:145:74)
at MergeMapSubscriber._tryNext (/var/lib/jenkins/workspace/angular test/node_modules/rxjs/internal/operators/mergeMap.js:69:27)
at MergeMapSubscriber._next (/var/lib/jenkins/workspace/angular test/node_modules/rxjs/internal/operators/mergeMap.js:59:18)
at MergeMapSubscriber.Subscriber.next (/var/lib/jenkins/workspace/angular test/node_modules/rxjs/internal/Subscriber.js:66:18)
at AsyncAction.dispatch [as work] (/var/lib/jenkins/workspace/angular test/node_modules/rxjs/internal/observable/timer.js:31:16)
at AsyncAction._execute (/var/lib/jenkins/workspace/angular test/node_modules/rxjs/internal/scheduler/AsyncAction.js:71:18)
at AsyncAction.execute (/var/lib/jenkins/workspace/angular test/node_modules/rxjs/internal/scheduler/AsyncAction.js:59:26)
at AsyncScheduler.flush (/var/lib/jenkins/workspace/angular test/node_modules/rxjs/internal/scheduler/AsyncScheduler.js:52:32)
at listOnTimeout (internal/timers.js:549:17)
at processTimers (internal/timers.js:492:7)
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! [email protected] test: `start-server-and-test start http://localhost:3030 cy:run`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the [email protected] test script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm ERR! A complete log of this run can be found in:
npm ERR! /var/lib/jenkins/.npm/_logs/2020-04-09T11_06_30_762Z-debug.log
Build step 'Execute shell' marked build as failure
Finished: FAILURE
and this is the verbose log:
0 info it worked if it ends with ok
1 verbose cli [
1 verbose cli '/opt/local/node/node-v12.16.1-linux-x64/bin/node',
1 verbose cli '/opt/local/node/12/bin/npm',
1 verbose cli 'run',
1 verbose cli 'test'
1 verbose cli ]
2 info using [email protected]
3 info using [email protected]
4 verbose run-script [ 'pretest', 'test', 'posttest' ]
5 info lifecycle [email protected]~pretest: [email protected]
6 info lifecycle [email protected]~test: [email protected]
7 verbose lifecycle [email protected]~test: unsafe-perm in lifecycle true
8 verbose lifecycle [email protected]~test: PATH: /opt/local/node/node-v12.16.1-linux-x64/lib/node_modules/npm/node_modules/npm-lifecycle/node-gyp-bin:/var/lib/jenkins/workspace/angular test/node_modules/.bin:/opt/local/node/12/bin:/opt/local/java/8.0/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin
9 verbose lifecycle [email protected]~test: CWD: /var/lib/jenkins/workspace/angular test
10 silly lifecycle [email protected]~test: Args: [ '-c', 'start-server-and-test start http://localhost:3030 cy:run' ]
11 silly lifecycle [email protected]~test: Returned: code: 1 signal: null
12 info lifecycle [email protected]~test: Failed to exec test script
13 verbose stack Error: [email protected] test: `start-server-and-test start http://localhost:3030 cy:run`
13 verbose stack Exit status 1
13 verbose stack at EventEmitter.<anonymous> (/opt/local/node/node-v12.16.1-linux-x64/lib/node_modules/npm/node_modules/npm-lifecycle/index.js:332:16)
13 verbose stack at EventEmitter.emit (events.js:311:20)
13 verbose stack at ChildProcess.<anonymous> (/opt/local/node/node-v12.16.1-linux-x64/lib/node_modules/npm/node_modules/npm-lifecycle/lib/spawn.js:55:14)
13 verbose stack at ChildProcess.emit (events.js:311:20)
13 verbose stack at maybeClose (internal/child_process.js:1021:16)
13 verbose stack at Process.ChildProcess._handle.onexit (internal/child_process.js:286:5)
14 verbose pkgid [email protected]
15 verbose cwd /var/lib/jenkins/workspace/angular test
16 verbose Linux 4.15.0-96-generic
17 verbose argv "/opt/local/node/node-v12.16.1-linux-x64/bin/node" "/opt/local/node/12/bin/npm" "run" "test"
18 verbose node v12.16.1
19 verbose npm v6.13.4
20 error code ELIFECYCLE
21 error errno 1
22 error [email protected] test: `start-server-and-test start http://localhost:3030 cy:run`
22 error Exit status 1
23 error Failed at the [email protected] test script.
23 error This is probably not a problem with npm. There is likely additional logging output above.
24 verbose exit [ 1, true ]
Do you have any hint?
While it's not obvious from the error message, it seems that you are hitting the the timeout for start-server-and-test
. Since starting your server appears to include a compilation step it might take some time. You can increase the timeout (default 5 min) by setting the environment variable WAITON_TIMEOUT
to the desired timeout in milliseconds. Alternatively, you could make a static build and serve it by something else than the devserver. For example an express server.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With