Protractor tests in Maven build with Jenkins
我目前正在尝试通过将protractor测试放入正在执行的Maven构建中,从而将protractor测试集成到Jenkins构建中。由于我要测试的计算机上未安装protractor,因此将其放入了pom.xml:
1 2 3 4 5 6 7 8 9 | <execution> <id>run npm install protractor </id> <goals> <goal>npm</goal> </goals> <configuration> install -g protractor</arguments> </configuration> </execution> |
这将通过Jenkins产生以下输出:
1 2 3 4 5 6 7 | [INFO] --- frontend-maven-plugin:1.6:npm (run npm install protractor) @ cpc-fe-impl --- [INFO] Running 'npm install -g protractor' in /var/lib/jenkins/workspace/VF-CPC/cpc-fe/cpc-fe/cpc-fe-impl/angular [WARNING] npm WARN deprecated [email protected]: request has been deprecated, see https://github.com/request/request/issues/3142 [INFO] /var/lib/jenkins/workspace/VF-CPC/cpc-fe/cpc-fe/cpc-fe-impl/target/bin/protractor -> /var/lib/jenkins/workspace/VF-CPC/cpc-fe/cpc-fe/cpc-fe-impl/target/lib/node_modules/protractor/bin/protractor [INFO] /var/lib/jenkins/workspace/VF-CPC/cpc-fe/cpc-fe/cpc-fe-impl/target/bin/webdriver-manager -> /var/lib/jenkins/workspace/VF-CPC/cpc-fe/cpc-fe/cpc-fe-impl/target/lib/node_modules/protractor/bin/webdriver-manager [INFO] + [email protected] [INFO] added 151 packages from 191 contributors in 8.082s |
但是当我稍后尝试使用greengerong的maven-ng-protractor插件在同一pom.xml中执行测试时:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 | <plugin> <groupId>com.github.greengerong</groupId> maven-ng-protractor</artifactId> <version>0.0.2</version> <configuration> <configFile>angular/e2e/protractor-jenkins.conf.js</configFile> </configuration> <executions> <execution> <id>ng-protractor</id> <phase>integration-test</phase> <goals> <goal>run</goal> </goals> </execution> </executions> </plugin> |
protractor安装似乎消失了,测试没有执行
1 2 3 4 5 6 7 8 9 10 | [INFO] --- maven-ng-protractor:0.0.2:run (ng-protractor) @ cpc-fe-impl --- [INFO] protractor:protractor [INFO] configFile:/var/lib/jenkins/workspace/VF-CPC/cpc-fe/cpc-fe/cpc-fe-impl/angular/e2e/protractor-jenkins.conf.js [INFO] Executing protractor test Suite ... [INFO] Command:/var/lib/jenkins/workspace/VF-CPC/cpc-fe/cpc-fe/cpc-fe-impl/angular/e2e/protractor-jenkins.conf.js [ERROR] Run protractor test error: java.io.IOException: Cannot run program"protractor": error=2, Datei oder Verzeichnis nicht gefunden at java.lang.ProcessBuilder.start (ProcessBuilder.java:1048) at com.github.greengerong.ProtractorService.exec (ProtractorService.java:34) ... |
有人知道如何解决此问题吗?我已经尝试通过配置Jenkins构建并将我的命令作为shell脚本执行而在不使用Maven的情况下运行protractor测试,但是在那里也找不到protractor(和npm)。
在此先感谢!
通过用于Jenkins的NodeJS插件在全局安装protractor来解决此问题