当我右键单击pom.xml
并运行Maven测试时,我能够运行我的测试。
之后我在Jenkins中配置了相同的项目,但Jenkins未能使用以下错误构建。有人可以帮助我。
[INFO] Compiling 17 source files to C:\Users\user\.jenkins\workspace\mavenproj\target\test-classes
[INFO] -------------------------------------------------------------
[ERROR] COMPILATION ERROR :
[INFO] -------------------------------------------------------------
[ERROR] /C:/Users/user/.jenkins/workspace/mavenproj/src/test/java/helpers/Hooks.java:[28,31] generics are not supported in -source 1.4
(use -source 5 or higher to enable generics)
[ERROR] /C:/Users/user/.jenkins/workspace/mavenproj/src/test/java/helpers/Hooks.java:[28,75] diamond operator is not supported in -source 1.4
(use -source 7 or higher to enable diamond operator)
[ERROR] /C:/Users/user/.jenkins/workspace/mavenproj/src/test/java/helpers/Hooks.java:[35,10] annotations are not supported in -source 1.4
(use -source 5 or higher to enable annotations)
[ERROR] /C:/Users/user/.jenkins/workspace/mavenproj/src/test/java/helpers/utils.java:[25,38] ';' expected
[ERROR] /C:/Users/user/.jenkins/workspace/mavenproj/src/test/java/helpers/utils.java:[25,40] not a statement
[ERROR] /C:/Users/user/.jenkins/workspace/mavenproj/src/test/java/helpers/utils.java:[25,44] ';' expected
[ERROR] /C:/Users/user/.jenkins/workspace/mavenproj/src/test/java/helpers/utils.java:[25,45] not a statement
[ERROR] /C:/Users/user/.jenkins/workspace/mavenproj/src/test/java/helpers/utils.java:[25,49] ';' expected
[ERROR] /C:/Users/user/.jenkins/workspace/mavenproj/src/test/java/helpers/utils.java:[25,50] not a statement
[ERROR] /C:/Users/user/.jenkins/workspace/mavenproj/src/test/java/helpers/utils.java:[25,54] ';' expected
[ERROR] /C:/Users/user/.jenkins/workspace/mavenproj/src/test/java/helpers/utils.java:[145,67] generics are not supported in -source 1.4
等
答案 0 :(得分:0)
您必须配置maven-compiler-plugin来设置源/目标:
<project>
[...]
<build>
[...]
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.5.1</version>
<configuration>
<source>1.7</source>
<target>1.7</target>
</configuration>
</plugin>
</plugins>
[...]
</build>
[...]
</project>
这意味着您需要修复项目。顺便说一句:詹金斯并不抱怨你的pom项目设置错误。从未在命令行上测试过。 IDE与命令行不同。