Skip to content

Commit

Permalink
fixed 43438
Browse files Browse the repository at this point in the history
  • Loading branch information
Artem Fedorov committed Apr 12, 2017
1 parent a67b1fc commit 2d298b2
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 7 deletions.
Expand Up @@ -431,12 +431,12 @@ protected static List<FilePath> locatePerformanceReports(FilePath workspace, Str
return files;
}

protected List<PerformanceReportParser> getParsers(FilePath workspace, EnvVars env) throws IOException, InterruptedException {
protected List<PerformanceReportParser> getParsers(Run<?, ?> build, FilePath workspace, PrintStream logger, EnvVars env) throws IOException, InterruptedException {
final List<PerformanceReportParser> parsers = new ArrayList<PerformanceReportParser>();
if (sourceDataFiles != null) {
for (String filePath : sourceDataFiles.split(";")) {
if (!filePath.isEmpty()) {
parsers.add(ParserFactory.getParser(workspace, filePath, env));
parsers.add(ParserFactory.getParser(build, workspace, logger, filePath, env));
}
}
}
Expand Down Expand Up @@ -484,7 +484,7 @@ public void perform(@Nonnull Run<?, ?> run, @Nonnull FilePath workspace, @Nonnul
Result result = Result.SUCCESS;
run.setResult(Result.SUCCESS);
EnvVars env = run.getEnvironment(listener);
final List<PerformanceReportParser> parsers = getParsers(workspace, env);
final List<PerformanceReportParser> parsers = getParsers(run, workspace, logger, env);

Collection<PerformanceReport> parsedReports = Collections.emptyList();
String glob = null;
Expand Down
Expand Up @@ -2,8 +2,12 @@

import hudson.EnvVars;
import hudson.FilePath;
import hudson.model.Run;
import hudson.plugins.performance.PerformancePublisher;

import java.io.File;
import java.io.IOException;
import java.io.PrintStream;
import java.util.Hashtable;
import java.util.Map;

Expand All @@ -21,17 +25,22 @@ public class ParserFactory {
defaultGlobPatterns.put("**/*.wrk", WrkSummarizerParser.class.getSimpleName());
}

public static PerformanceReportParser getParser(FilePath workspace, String glob, EnvVars env) throws IOException, InterruptedException {
public static PerformanceReportParser getParser(Run<?, ?> build, FilePath workspace, PrintStream logger, String glob, EnvVars env) throws IOException, InterruptedException {
if (defaultGlobPatterns.containsKey(glob)) {
return getParser(defaultGlobPatterns.get(glob), glob);
}

String expandGlob = env.expand(glob);
try {
FilePath[] pathList = workspace.list(expandGlob);
if (pathList.length > 0) {
return getParser(ParserDetector.detect(pathList[0].getRemote()), glob);

for (FilePath src : pathList) {
final File localReport = PerformancePublisher.getPerformanceReport(build, "Parser Factory", src.getName());
if (src.isDirectory()) {
logger.println("Performance: File '" + src.getName() + "' is a directory, not a Performance Report");
continue;
}
src.copyTo(new FilePath(localReport));
return getParser(ParserDetector.detect(localReport.getPath()), glob);
}
} catch (IOException ignored) {
}
Expand Down

0 comments on commit 2d298b2

Please sign in to comment.