提交 e4914db5 编写于 作者: O Olivier Lamy

[FIXED JENKINS-9326] Jenkins Maven build does not recognize Tycho surfire reports

上级 988b1a20
...@@ -88,7 +88,7 @@ public class SurefireArchiver extends MavenReporter { ...@@ -88,7 +88,7 @@ public class SurefireArchiver extends MavenReporter {
// so that we can record this as yellow. // so that we can record this as yellow.
// note that because of the way Maven works, just updating system property at this point is too late // note that because of the way Maven works, just updating system property at this point is too late
XmlPlexusConfiguration c = (XmlPlexusConfiguration) mojo.configuration.getChild("testFailureIgnore"); XmlPlexusConfiguration c = (XmlPlexusConfiguration) mojo.configuration.getChild("testFailureIgnore");
if(c!=null && c.getValue().equals("${maven.test.failure.ignore}") && System.getProperty("maven.test.failure.ignore")==null) { if(c!=null && c.getValue() != null && c.getValue().equals("${maven.test.failure.ignore}") && System.getProperty("maven.test.failure.ignore")==null) {
if (maven3orLater( build.getMavenBuildInformation().getMavenVersion() )) { if (maven3orLater( build.getMavenBuildInformation().getMavenVersion() )) {
String fieldName = "testFailureIgnore"; String fieldName = "testFailureIgnore";
if (mojo.mojoExecution.getConfiguration().getChild( fieldName ) != null) { if (mojo.mojoExecution.getConfiguration().getChild( fieldName ) != null) {
...@@ -245,6 +245,7 @@ public class SurefireArchiver extends MavenReporter { ...@@ -245,6 +245,7 @@ public class SurefireArchiver extends MavenReporter {
private boolean isSurefireTest(MojoInfo mojo) { private boolean isSurefireTest(MojoInfo mojo) {
if ((!mojo.is("com.sun.maven", "maven-junit-plugin", "test")) if ((!mojo.is("com.sun.maven", "maven-junit-plugin", "test"))
&& (!mojo.is("org.sonatype.flexmojos", "flexmojos-maven-plugin", "test-run")) && (!mojo.is("org.sonatype.flexmojos", "flexmojos-maven-plugin", "test-run"))
&& (!mojo.is("org.sonatype.tycho", "maven-osgi-test-plugin", "test"))
&& (!mojo.is("org.apache.maven.plugins", "maven-surefire-plugin", "test")) && (!mojo.is("org.apache.maven.plugins", "maven-surefire-plugin", "test"))
&& (!mojo.is("org.apache.maven.plugins", "maven-failsafe-plugin", "integration-test"))) && (!mojo.is("org.apache.maven.plugins", "maven-failsafe-plugin", "integration-test")))
return false; return false;
...@@ -284,7 +285,12 @@ public class SurefireArchiver extends MavenReporter { ...@@ -284,7 +285,12 @@ public class SurefireArchiver extends MavenReporter {
if (((skipTests != null) && (skipTests))) { if (((skipTests != null) && (skipTests))) {
return false; return false;
} }
} } else if (mojo.is("org.sonatype.tycho", "maven-osgi-test-plugin", "test")) {
Boolean skipTests = mojo.getConfigurationValue("skipTest", Boolean.class);
if (((skipTests != null) && (skipTests))) {
return false;
}
}
} catch (ComponentConfigurationException e) { } catch (ComponentConfigurationException e) {
return false; return false;
......
...@@ -29,6 +29,8 @@ import hudson.model.AbstractBuild; ...@@ -29,6 +29,8 @@ import hudson.model.AbstractBuild;
import hudson.model.BuildListener; import hudson.model.BuildListener;
import hudson.scm.NullSCM; import hudson.scm.NullSCM;
import hudson.scm.SCM; import hudson.scm.SCM;
import org.apache.commons.io.FileUtils;
import org.apache.commons.io.IOUtils;
import java.io.File; import java.io.File;
import java.io.IOException; import java.io.IOException;
...@@ -42,12 +44,21 @@ import java.net.URL; ...@@ -42,12 +44,21 @@ import java.net.URL;
public class ExtractResourceSCM extends NullSCM { public class ExtractResourceSCM extends NullSCM {
private final URL zip; private final URL zip;
private String parentFolder;
public ExtractResourceSCM(URL zip) { public ExtractResourceSCM(URL zip) {
if(zip==null) if(zip==null)
throw new IllegalArgumentException(); throw new IllegalArgumentException();
this.zip = zip; this.zip = zip;
} }
public ExtractResourceSCM(URL zip, String parentFolder) {
if(zip==null)
throw new IllegalArgumentException();
this.zip = zip;
this.parentFolder = parentFolder;
}
@Override @Override
public boolean checkout(AbstractBuild build, Launcher launcher, FilePath workspace, BuildListener listener, File changeLogFile) throws IOException, InterruptedException { public boolean checkout(AbstractBuild build, Launcher launcher, FilePath workspace, BuildListener listener, File changeLogFile) throws IOException, InterruptedException {
if (workspace.exists()) { if (workspace.exists()) {
...@@ -56,6 +67,12 @@ public class ExtractResourceSCM extends NullSCM { ...@@ -56,6 +67,12 @@ public class ExtractResourceSCM extends NullSCM {
} }
listener.getLogger().println("Staging "+zip); listener.getLogger().println("Staging "+zip);
workspace.unzipFrom(zip.openStream()); workspace.unzipFrom(zip.openStream());
if (parentFolder != null) {
System.out.println("workspace " + workspace.getRemote());
//Thread.sleep( 100000 );
FileUtils.copyDirectory( new File(workspace.getRemote() + "/" + parentFolder), new File( workspace.getRemote()));
//FileUtils.moveDirectory( new File(workspace.getRemote() + "/" + parentFolder), new File( workspace.getRemote()));
}
return true; return true;
} }
} }
package hudson.maven; package hudson.maven;
/* /*
* Olivier Lamy
* Licensed to the Apache Software Foundation (ASF) under one * Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file * or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information * distributed with this work for additional information
...@@ -28,6 +29,7 @@ import java.io.File; ...@@ -28,6 +29,7 @@ import java.io.File;
import java.io.FilenameFilter; import java.io.FilenameFilter;
import java.io.IOException; import java.io.IOException;
import hudson.tasks.test.AbstractTestResultAction;
import hudson.tasks.test.TestResult; import hudson.tasks.test.TestResult;
import hudson.tasks.test.TestResultProjectAction; import hudson.tasks.test.TestResultProjectAction;
import org.apache.commons.io.FileUtils; import org.apache.commons.io.FileUtils;
...@@ -193,6 +195,32 @@ public class Maven3BuildTest extends HudsonTestCase { ...@@ -193,6 +195,32 @@ public class Maven3BuildTest extends HudsonTestCase {
.getAction(TestResultProjectAction.class).getLastTestResultAction().getTotalCount(); .getAction(TestResultProjectAction.class).getLastTestResultAction().getTotalCount();
assertEquals(4, totalCount); assertEquals(4, totalCount);
} }
@Bug(9326)
public void testTychoTestResults() throws Exception {
MavenInstallation mavenInstallation = configureMaven3();
MavenModuleSet m = createMavenProject();
m.setRootPOM( "org.foobar.build/pom.xml" );
m.setMaven( mavenInstallation.getName() );
m.getReporters().add(new TestReporter());
m.setScm(new ExtractResourceSCM(getClass().getResource("JENKINS-9326.zip"),"foobar"));
m.setGoals("verify");
buildAndAssertSuccess(m);
System.out.println("modules size " + m.getModules());
MavenModule testModule = null;
for (MavenModule mavenModule : m.getModules()) {
System.out.println("module " + mavenModule.getName() + "/" + mavenModule.getDisplayName());
if ("org.foobar:org.foobar.test".equals( mavenModule.getName() )) testModule = mavenModule;
}
AbstractTestResultAction trpa = testModule.getLastBuild().getTestResultAction();
int totalCount = trpa.getTotalCount();
assertEquals(1, totalCount);
}
private static class TestReporter extends MavenReporter { private static class TestReporter extends MavenReporter {
@Override @Override
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册