gpt4 book ai didi

angular - Jenkins 运行 Cypress 测试以超时结束

转载 作者:行者123 更新时间:2023-12-03 14:47:48 24 4
gpt4 key购买 nike

我在 Linux 服务器上安装了 Jenkins(我没有 docker 容器,只是一个普通服务器)。我安装了所有建议的插件,以便为 Java 和 Angular 应用程序自动化。

现在我在运行 cypress tests 时遇到问题.我可以构建 Angular 应用程序,但是在 headless 模式下运行 cypress test 时遇到了问题。

我创建了一个“自由式项目”(不是管道),只是为了运行测试。

enter image description here

这是我的 Angular 项目中的相关脚本部分:

"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"
},

如前所述 here ,运行脚本测试它应该可以工作,cypress 应该等待应用程序启动并运行。

但是,当我运行 Jenkins 构建时,出现以下错误:
    npm install
npm WARN deprecated popper.js@1.16.1: You can find the new Popper v2 at @popperjs/core, this package is dedicated to the legacy v1
npm WARN deprecated request@2.88.2: request has been deprecated, see https://github.com/request/request/issues/3142
npm WARN deprecated urix@0.1.0: Please see https://github.com/lydell/urix#deprecated
npm WARN deprecated resolve-url@0.2.1: https://github.com/lydell/resolve-url#deprecated

> websocket@1.0.31 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'

> node-sass@4.13.1 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

> core-js@3.6.4 postinstall /var/lib/jenkins/workspace/angular test/node_modules/core-js
> node -e "try{require('./postinstall')}catch(e){}"


> @angular/cli@9.1.1 postinstall /var/lib/jenkins/workspace/angular test/node_modules/@angular/cli
> node ./bin/postinstall/script.js


> cypress@4.3.0 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


> ngx-infinite-scroll@8.0.1 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


> node-sass@4.13.1 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

> test@0.0.6-b04032020 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"

> test@0.0.6-b04032020 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! test@0.0.6-b04032020 test: `start-server-and-test start http://localhost:3030 cy:run`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the test@0.0.6-b04032020 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

这是详细日志:
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 npm@6.13.4
3 info using node@v12.16.1
4 verbose run-script [ 'pretest', 'test', 'posttest' ]
5 info lifecycle test@0.0.6~pretest: test@0.0.6
6 info lifecycle test@0.0.6~test: test@0.0.6
7 verbose lifecycle test@0.0.6~test: unsafe-perm in lifecycle true
8 verbose lifecycle test@0.0.6~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 test@0.0.6~test: CWD: /var/lib/jenkins/workspace/angular test
10 silly lifecycle test@0.0.6~test: Args: [ '-c', 'start-server-and-test start http://localhost:3030 cy:run' ]
11 silly lifecycle test@0.0.6~test: Returned: code: 1 signal: null
12 info lifecycle test@0.0.6~test: Failed to exec test script
13 verbose stack Error: test@0.0.6 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 test@0.0.6
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 test@0.0.6 test: `start-server-and-test start http://localhost:3030 cy:run`
22 error Exit status 1
23 error Failed at the test@0.0.6 test script.
23 error This is probably not a problem with npm. There is likely additional logging output above.
24 verbose exit [ 1, true ]

你有什么提示吗?

最佳答案

虽然从错误消息中看并不明显,但您似乎遇到了 timeoutstart-server-and-test .由于启动服务器似乎包括编译步骤,因此可能需要一些时间。您可以通过设置环境变量 WAITON_TIMEOUT 来增加超时时间(默认为 5 分钟)。到所需的超时(以毫秒为单位)。或者,您可以进行静态构建并由除开发服务器以外的其他工具提供服务。例如快速服务器。

关于angular - Jenkins 运行 Cypress 测试以超时结束,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/61120755/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com