我有一个 Jenkins 平台,它调用 maven 来进行单元测试(使用 surefire 插件)和集成测试(使用故障安全插件)。当集成测试出现错误时,Jenkins 认为构建成功。这种行为正常吗?我希望它认为构建不稳定。更一般地说,您知道 Jenkins 如何读取和解释构建结果以将构建视为成功或不稳定吗?我在网上某处读到故障安全报告必须重定向到万无一失的报告路径。我做了id,但问题仍然存在。
pom.xml:
[...]
<plugin>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.10</version>
<configuration>
<disableXmlReport>false</disableXmlReport>
</configuration>
<executions>
<execution>
<id>default-test</id>
<phase>test</phase>
<configuration>
<includes>
<include>**/tests/**</include>
</includes>
<excludes>
<exclude>**/testsIntegration/**</exclude>
</excludes>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-failsafe-plugin</artifactId>
<version>2.7.2</version>
<configuration>
<disableXmlReport>false</disableXmlReport>
<reportsDirectory>${basedir}/target/surefire-reports</reportsDirectory>
<includes>
<include>com/acelys/conventionsJuridiques/*.java</include>
<!-- ... inclure les tests Selenium -->
</includes>
</configuration>
<executions>
<execution>
<id>integration-test</id>
<phase>integration-test</phase>
<goals>
<goal>integration-test</goal>
</goals>
<configuration>
<includes>
<include>**/testsIntegration/**</include>
</includes>
<excludes>
<exclude>**/tests/**</exclude>
</excludes>
</configuration>
</execution>
</executions>
</plugin>
[...]
詹金斯的输出:
[...]
mojoStarted org.apache.maven.plugins:maven-failsafe-plugin:2.7.2(integration-test)
[INFO]
[INFO] --- maven-failsafe-plugin:2.7.2:integration-test (integration-test) @ BaseContrats ---
[INFO] Failsafe report directory: C:\jenkins_home\workspace\Base Contrats EXT JS MAVEN\target\surefire-reports
-------------------------------------------------------
T E S T S
-------------------------------------------------------
Running com.acelys.conventionsJuridiques.testsIntegration.connexion.TestConnexion
Tests run: 1, Failures: 1, Errors: 0, Skipped: 0, Time elapsed: 23.971 sec <<< FAILURE!
Results :
Failed tests:
testHomePage(com.acelys.conventionsJuridiques.testsIntegration.connexion.TestConnexion)
Tests run: 1, Failures: 1, Errors: 0, Skipped: 0
[WARNING] File encoding has not been set, using platform encoding Cp1252, i.e. build is platform dependent!
mojoSucceeded org.apache.maven.plugins:maven-failsafe-plugin:2.7.2(integration-test)
mojoStarted org.apache.tomcat.maven:tomcat6-maven-plugin:2.1-SNAPSHOT(tomcat-shutdown)
[INFO]
[INFO] --- tomcat6-maven-plugin:2.1-SNAPSHOT:shutdown (tomcat-shutdown) @ BaseContrats ---
25 févr. 2013 09:32:08 org.apache.coyote.http11.Http11Protocol destroy
INFO: Stopping Coyote HTTP/1.1 on http-8080
25 févr. 2013 09:32:08 org.apache.catalina.core.ApplicationContext log
INFO: Closing Spring root WebApplicationContext
25 févr. 2013 09:32:08 org.apache.catalina.loader.WebappClassLoader clearReferencesJdbc
mojoSucceeded org.apache.tomcat.maven:tomcat6-maven-plugin:2.1-SNAPSHOT(tomcat-shutdown)
projectSucceeded BaseContrats:BaseContrats:1.0-SNAPSHOT
sessionEnded
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 2:07.408s
[INFO] Finished at: Mon Feb 25 09:32:08 CET 2013
[INFO] Final Memory: 13M/51M
[INFO] ------------------------------------------------------------------------
Projects to build: [MavenProject: BaseContrats:BaseContrats:1.0-SNAPSHOT @ C:\jenkins_home\workspace\Base Contrats EXT JS MAVEN\pom.xml]
[JENKINS] Archiving C:\jenkins_home\workspace\Base Contrats EXT JS MAVEN\pom.xml to C:\jenkins_home\jobs\Base Contrats EXT JS MAVEN\modules\BaseContrats$BaseContrats\builds\2013-02-25_09-29-58\archive\BaseContrats\BaseContrats\1.0-SNAPSHOT\BaseContrats-1.0-SNAPSHOT.pom
[JENKINS] Archiving C:\jenkins_home\workspace\Base Contrats EXT JS MAVEN\target\ConventionsJuridiques.war to C:\jenkins_home\jobs\Base Contrats EXT JS MAVEN\modules\BaseContrats$BaseContrats\builds\2013-02-25_09-29-58\archive\BaseContrats\BaseContrats\1.0-SNAPSHOT\BaseContrats-1.0-SNAPSHOT.war
channel stopped
Finished: SUCCESS