Skip to content

Commit

Permalink
Fix for [JENKINS-18950] issue (reports => running out of memory).
Browse files Browse the repository at this point in the history
  • Loading branch information
Jakub Pawlaczyk committed Aug 7, 2013
1 parent 0e9529f commit 592c1dc
Show file tree
Hide file tree
Showing 3 changed files with 73 additions and 9 deletions.
Expand Up @@ -14,8 +14,14 @@
import hudson.tasks.BuildStepMonitor;
import hudson.tasks.Publisher;
import hudson.tasks.Recorder;
import hudson.FilePath;
import hudson.FilePath.FileCallable;
import hudson.remoting.VirtualChannel;

import java.io.File;
import java.io.FileFilter;
import java.io.IOException;
import java.util.List;

import net.sf.json.JSONObject;

Expand All @@ -28,8 +34,13 @@
import org.jenkinsci.plugins.valgrind.util.ValgrindEvaluator;
import org.jenkinsci.plugins.valgrind.util.ValgrindLogger;
import org.jenkinsci.plugins.valgrind.util.ValgrindSourceGrabber;
import org.jenkinsci.plugins.valgrind.MyFilePath;
import org.kohsuke.stapler.DataBoundConstructor;
import org.kohsuke.stapler.StaplerRequest;
import org.kohsuke.stapler.QueryParameter;

import org.apache.tools.ant.*;


/**
*
Expand Down Expand Up @@ -104,19 +115,38 @@ public boolean perform(AbstractBuild<?, ?> build, Launcher launcher, BuildListen
return false;
}


EnvVars env = build.getEnvironment();


FilePath baseFileFrom = build.getWorkspace();
FilePath baseFileTo = new FilePath(build.getRootDir());
ValgrindResultsScanner scanner = new ValgrindResultsScanner(valgrindPublisherConfig.getPattern());
String[] files = baseFileFrom.act(scanner);

ValgrindLogger.log(listener, "Files to copy:");
for (int i = 0; i < files.length; i++) {
ValgrindLogger.log(listener, files[i]);
}

for (int i = 0; i < files.length; i++) {
FilePath fileFrom = new FilePath(baseFileFrom, files[i]);
FilePath fileTo = new FilePath(baseFileTo, "valgrind-plugin/valgrind-results/" + files[i]);
ValgrindLogger.log(listener, "Copying " + files[i] + " to " + fileTo.getRemote());
fileFrom.copyTo(fileTo);
}


ValgrindLogger.log(listener, "Analysing valgrind results; configure Jenkins system log (ValgrindLogger) for details");

ValgrindParserResult parser = new ValgrindParserResult(env.expand(valgrindPublisherConfig.getPattern()));

ValgrindParserResult parser = new ValgrindParserResult("valgrind-plugin/valgrind-results/"+valgrindPublisherConfig.getPattern());
ValgrindResult valgrindResult = new ValgrindResult(build, parser);
ValgrindReport valgrindReport = valgrindResult.getReport();

new ValgrindEvaluator(valgrindPublisherConfig, listener).evaluate(valgrindReport, build, env);

ValgrindLogger.log(listener, "Analysing valgrind results");

ValgrindLogger.log(listener, "Analysing valgrind results");
ValgrindSourceGrabber sourceGrabber = new ValgrindSourceGrabber(listener, build.getModuleRoot());

if ( !sourceGrabber.init( build.getRootDir() ) )
Expand Down Expand Up @@ -227,6 +257,7 @@ public int getLinesAfter()
public ValgrindPublisherConfig getConfig()
{
return new ValgrindPublisherConfig();
}
}

}
}
}
@@ -1,6 +1,7 @@
package org.jenkinsci.plugins.valgrind;

import hudson.model.AbstractBuild;
import hudson.FilePath;

import java.io.IOException;
import java.io.Serializable;
Expand All @@ -17,6 +18,7 @@
import org.kohsuke.stapler.StaplerResponse;



public class ValgrindResult implements Serializable
{
private static final long serialVersionUID = -5347879997716170059L;
Expand Down Expand Up @@ -60,7 +62,8 @@ public ValgrindReport getReport() throws IOException, InterruptedException
return report; //for results serialized through older plugin version(s)
}
else {
return owner.getWorkspace().act(parser);
FilePath file = new FilePath(owner.getRootDir());
return file.act(parser);
}
}

Expand Down
@@ -0,0 +1,30 @@
package org.jenkinsci.plugins.valgrind;

import hudson.FilePath;
import hudson.Util;
import hudson.remoting.VirtualChannel;

import java.io.File;
import java.io.IOException;

import org.apache.tools.ant.DirectoryScanner;

public class ValgrindResultsScanner implements FilePath.FileCallable<String[]> {
private static final long serialVersionUID = -5475538646374717099L;
private String pattern;

public ValgrindResultsScanner(String pattern) {
this.pattern = pattern;
}

public String[] invoke(File basedir, VirtualChannel channel)
throws IOException, InterruptedException {
DirectoryScanner ds = new DirectoryScanner();
String[] includes = { pattern };
ds.setIncludes(includes);
ds.setBasedir(basedir);
ds.setCaseSensitive(true);
ds.scan();
return ds.getIncludedFiles();
}
}

0 comments on commit 592c1dc

Please sign in to comment.