使用 Jenkins 在 Maven 构建中进行 Protractor 测试
Protractor tests in Maven build with Jenkins
我目前正在尝试将量角器测试集成到 Jenkins 构建中,方法是将其放入正在执行的 Maven 构建中。由于量角器未安装在我要测试的机器上,我已将其放入 pom.xml:
<execution>
<id>run npm install protractor </id>
<goals>
<goal>npm</goal>
</goals>
<configuration>
<arguments>install -g protractor</arguments>
</configuration>
</execution>
这会通过 Jenkins 产生以下输出:
[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 request@2.88.2: 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] + protractor@7.0.0
[INFO] added 151 packages from 191 contributors in 8.082s
但是当我稍后尝试使用 greengerong 的 maven-ng-protractor 插件在同一个 pom.xml 中执行测试时:
<plugin>
<groupId>com.github.greengerong</groupId>
<artifactId>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>
量角器安装似乎消失了,测试未执行
[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 的量角器测试,但是在那里也找不到量角器(和 npm)。
提前致谢!
通过 Jenkins 的 NodeJS 插件全局安装量角器解决了这个问题
我目前正在尝试将量角器测试集成到 Jenkins 构建中,方法是将其放入正在执行的 Maven 构建中。由于量角器未安装在我要测试的机器上,我已将其放入 pom.xml:
<execution>
<id>run npm install protractor </id>
<goals>
<goal>npm</goal>
</goals>
<configuration>
<arguments>install -g protractor</arguments>
</configuration>
</execution>
这会通过 Jenkins 产生以下输出:
[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 request@2.88.2: 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] + protractor@7.0.0
[INFO] added 151 packages from 191 contributors in 8.082s
但是当我稍后尝试使用 greengerong 的 maven-ng-protractor 插件在同一个 pom.xml 中执行测试时:
<plugin>
<groupId>com.github.greengerong</groupId>
<artifactId>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>
量角器安装似乎消失了,测试未执行
[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 的量角器测试,但是在那里也找不到量角器(和 npm)。 提前致谢!
通过 Jenkins 的 NodeJS 插件全局安装量角器解决了这个问题