Skip to content
Permalink
Browse files

Fix JENKINS-9655 patch by Attila-Mihaly

  • Loading branch information...
manolo committed May 13, 2011
1 parent dd215a3 commit 9688edeb307c76453d2a8892646f6506054b591b
@@ -34,10 +34,10 @@ public PerformanceBuildAction(AbstractBuild<?, ?> pBuild, PrintStream logger,
this.parsers = parsers;
}

public PerformanceReportParser getParserById(String id) {
public PerformanceReportParser getParserByDisplayName(String displayName) {
if (parsers != null)
for (PerformanceReportParser parser : parsers)
if (parser.getDescriptor().getId().equals(id))
if (parser.getDescriptor().getDisplayName().equals(displayName))
return parser;
return null;
}
@@ -336,20 +336,22 @@ public void doRespondingTimeGraph(StaplerRequest request,

public List<String> getPerformanceReportList() {
this.performanceReportList = new ArrayList<String>(0);
if (this.project != null
&& this.project.getSomeBuildWithWorkspace() != null) {
File file = new File(
this.project.getSomeBuildWithWorkspace().getRootDir(),
PerformanceReportMap.getPerformanceReportDirRelativePath());
if (file.exists()) {
for (File performanceReportFile : file.listFiles()) {
this.performanceReportList.add(performanceReportFile.getName());
}
if (null == this.project) { return performanceReportList; }
if (null == this.project.getSomeBuildWithWorkspace()) { return performanceReportList; }
File file = new File(
this.project.getSomeBuildWithWorkspace().getRootDir(),
PerformanceReportMap.getPerformanceReportDirRelativePath());
if (!file.isDirectory()) { return performanceReportList; }

for (File entry : file.listFiles()) {
if (entry.isDirectory()) {
for (File e : entry.listFiles()) { this.performanceReportList.add(e.getName()); }
} else {
this.performanceReportList.add(entry.getName());
}
}
if (this.performanceReportList != null) {
Collections.sort(performanceReportList);
}

Collections.sort(performanceReportList);
return this.performanceReportList;
}

@@ -74,10 +74,10 @@ public PerformancePublisher(int errorFailedThreshold,
}

public static File getPerformanceReport(AbstractBuild<?, ?> build,
String performanceReportName) {
String parserDisplayName, String performanceReportName) {
return new File(
build.getRootDir(),
PerformanceReportMap.getPerformanceReportFileRelativePath(getPerformanceReportBuildFileName(performanceReportName)));
PerformanceReportMap.getPerformanceReportFileRelativePath(parserDisplayName, getPerformanceReportBuildFileName(performanceReportName)));
}

@Override
@@ -195,7 +195,7 @@ public boolean perform(AbstractBuild<?, ?> build, Launcher launcher,
return true;
}

List<File> localReports = copyReportsToMaster(build, logger, files);
List<File> localReports = copyReportsToMaster(build, logger, files, parser.getDescriptor().getDisplayName());
Collection<PerformanceReport> parsedReports = parser.parse(build,
localReports, listener);

@@ -220,11 +220,11 @@ public boolean perform(AbstractBuild<?, ?> build, Launcher launcher,
}

private List<File> copyReportsToMaster(AbstractBuild<?, ?> build,
PrintStream logger, List<FilePath> files) throws IOException,
PrintStream logger, List<FilePath> files, String parserDisplayName) throws IOException,
InterruptedException {
List<File> localReports = new ArrayList<File>();
for (FilePath src : files) {
final File localReport = getPerformanceReport(build, src.getName());
final File localReport = getPerformanceReport(build, parserDisplayName, src.getName());
if (src.isDirectory()) {
logger.println("Performance: File '" + src.getName()
+ "' is a directory, not a Performance Report");
@@ -72,7 +72,7 @@ public boolean accept(File f) {
// this may fail, if the build itself failed, we need to recover gracefully
if (dirs != null) {
for (File dir : dirs) {
PerformanceReportParser p = buildAction.getParserById(dir.getName());
PerformanceReportParser p = buildAction.getParserByDisplayName(dir.getName());
if (p != null) {
addAll(p.parse(getBuild(), Arrays.asList(dir.listFiles()), listener));
}
@@ -162,19 +162,19 @@ public void setPerformanceReportMap(
}

public static String getPerformanceReportFileRelativePath(
String reportFileName) {
return getRelativePath(reportFileName);
String parserDisplayName, String reportFileName) {
return getRelativePath(parserDisplayName, reportFileName);
}

public static String getPerformanceReportDirRelativePath() {
return getRelativePath(null);
return getRelativePath();
}

private static String getRelativePath(String reportFileName) {
private static String getRelativePath(String... suffixes) {
StringBuilder sb = new StringBuilder(100);
sb.append(PERFORMANCE_REPORTS_DIRECTORY);
if (reportFileName != null) {
sb.append("/").append(reportFileName);
for (String suffix : suffixes) {
sb.append(File.separator).append(suffix);
}
return sb.toString();
}

0 comments on commit 9688ede

Please sign in to comment.
You can’t perform that action at this time.