Skip to content

Commit

Permalink
JENKINS-32983: fix parsing results from slave
Browse files Browse the repository at this point in the history
  • Loading branch information
jcarsique committed Feb 18, 2016
1 parent 401b064 commit 6aad43f
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 50 deletions.
Expand Up @@ -112,9 +112,6 @@ public boolean accept( File file, String s )
BuildJob buildJob = reader.read( is );
MavenInvokerResult mavenInvokerResult = MavenInvokerRecorder.map( buildJob );
mavenInvokerResult.mavenModuleName = pom.getArtifactId();

logger.println( "mavenInvokerResult:" + mavenInvokerResult );

mavenInvokerResults.mavenInvokerResults.add( mavenInvokerResult );
}
catch ( XmlPullParserException e )
Expand All @@ -128,6 +125,7 @@ public boolean accept( File file, String s )
IOUtils.closeQuietly( is );
}
}
logger.println( "Finished parsing Maven Invoker results" );

int failedCount = build.execute( new MavenBuildProxy.BuildCallable<Integer, IOException>()
{
Expand Down
Expand Up @@ -27,31 +27,24 @@
import hudson.model.AbstractBuild;
import hudson.model.AbstractProject;
import hudson.model.BuildListener;
import hudson.remoting.VirtualChannel;
import hudson.tasks.BuildStepDescriptor;
import hudson.tasks.BuildStepMonitor;
import hudson.tasks.Publisher;
import hudson.tasks.Recorder;

import org.apache.commons.io.IOUtils;
import org.apache.maven.plugin.invoker.model.BuildJob;
import org.apache.maven.plugin.invoker.model.io.xpp3.BuildJobXpp3Reader;
import org.codehaus.plexus.util.xml.pull.XmlPullParserException;
import org.jenkinsci.plugins.maveninvoker.results.MavenInvokerResult;
import org.jenkinsci.plugins.maveninvoker.results.MavenInvokerResults;
import org.kohsuke.stapler.DataBoundConstructor;

import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintStream;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

import jenkins.SlaveToMasterFileCallable;

/**
* @author Olivier Lamy
*/
Expand Down Expand Up @@ -83,13 +76,11 @@ public boolean perform( AbstractBuild<?, ?> build, Launcher launcher, BuildListe
PrintStream logger = listener.getLogger();
logger.println( "performing MavenInvokerRecorder, filenamePattern:'" + filenamePattern + "'" );
FilePath[] filePaths = locateReports( build.getWorkspace(), filenamePattern );
logger.println( "found reports:" + Arrays.asList( filePaths ) );
logger.println( "Found reports:" + Arrays.asList( filePaths ) );
try
{
MavenInvokerResults mavenInvokerResults = parseReports( filePaths, listener, build );

MavenInvokerBuildAction action = new MavenInvokerBuildAction( build, mavenInvokerResults );

build.addAction( action );
}
catch ( Exception e )
Expand All @@ -108,37 +99,11 @@ static MavenInvokerResults parseReports( FilePath[] filePaths, BuildListener lis
saveReports( getMavenInvokerReportsDirectory( build ), filePaths );
for ( final FilePath filePath : filePaths )
{
BuildJob buildJob = filePath.act( new SlaveToMasterFileCallable<BuildJob>()
{
private static final long serialVersionUID = 1L;

@Override
public BuildJob invoke( File f, VirtualChannel channel )
throws IOException, InterruptedException
{
InputStream is = new FileInputStream( f );
try
{
return reader.read( is );
}
catch ( XmlPullParserException e )
{
throw new IOException( e );
}
finally
{
IOUtils.closeQuietly( is );
}
}
} );

BuildJob buildJob = reader.read( filePath.read() );
MavenInvokerResult mavenInvokerResult = map( buildJob );

logger.println( "mavenInvokerResult:" + mavenInvokerResult );

mavenInvokerResults.mavenInvokerResults.add( mavenInvokerResult );

}
logger.println( "Finished parsing Maven Invoker results" );
return mavenInvokerResults;
}

Expand Down Expand Up @@ -219,7 +184,6 @@ static FilePath[] locateBuildLogs( FilePath workspace, String basePath )
static FilePath[] locateReports( FilePath workspace, String filenamePattern )
throws IOException, InterruptedException
{

// First use ant-style pattern
try
{
Expand Down Expand Up @@ -257,7 +221,6 @@ static FilePath[] locateReports( FilePath workspace, String filenamePattern )
public static final class DescriptorImpl
extends BuildStepDescriptor<Publisher>
{

@Override
public boolean isApplicable( Class<? extends AbstractProject> aClass )
{
Expand Down
Expand Up @@ -27,9 +27,6 @@
*/
public class MavenInvokerResult implements Serializable {

/**
*
*/
private static final long serialVersionUID = 1L;

// used with mavenReporter
Expand Down Expand Up @@ -70,4 +67,5 @@ public String toString() {
sb.append('}');
return sb.toString();
}

}
Expand Up @@ -33,10 +33,6 @@
* @author Olivier Lamy
*/
public class MavenInvokerResults implements Serializable {

/**
*
*/
private static final long serialVersionUID = 1L;

public List<MavenInvokerResult> mavenInvokerResults = new CopyOnWriteArrayList<MavenInvokerResult>();
Expand Down

0 comments on commit 6aad43f

Please sign in to comment.