Fixed config values not being retained and added path to specify plugin url

This commit is contained in:
Kingsley Hendrickse 2012-04-17 14:41:51 +01:00
parent 45327f377f
commit ff1f41ee01
7 changed files with 63 additions and 42 deletions

View File

@ -1,5 +1,10 @@
<?xml version="1.0" encoding="UTF-8"?>
<module org.jetbrains.idea.maven.project.MavenProjectsManager.isMavenModule="true" type="JAVA_MODULE" version="4">
<component name="FacetManager">
<facet type="gwt" name="GWT">
<configuration />
</facet>
</component>
<component name="NewModuleRootManager" LANGUAGE_LEVEL="JDK_1_5" inherit-compiler-output="false">
<output url="file://$MODULE_DIR$/target/classes" />
<output-test url="file://$MODULE_DIR$/target/test-classes" />
@ -10,8 +15,11 @@
<excludeFolder url="file://$MODULE_DIR$/target/classes" />
<excludeFolder url="file://$MODULE_DIR$/target/cucumber-reports" />
<excludeFolder url="file://$MODULE_DIR$/target/generated-sources/groovy-stubs" />
<excludeFolder url="file://$MODULE_DIR$/target/inject-tests" />
<excludeFolder url="file://$MODULE_DIR$/target/jenkins-for-test" />
<excludeFolder url="file://$MODULE_DIR$/target/surefire" />
<excludeFolder url="file://$MODULE_DIR$/target/surefire-reports" />
<excludeFolder url="file://$MODULE_DIR$/target/test-classes" />
<excludeFolder url="file://$MODULE_DIR$/target/work" />
</content>
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
@ -78,6 +86,7 @@
<orderEntry type="library" scope="PROVIDED" name="Maven: jfree:jfreechart:1.0.9" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: jfree:jcommon:1.0.12" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: org.apache.ant:ant:1.8.0" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: org.apache.ant:ant-launcher:1.8.0" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: commons-digester:commons-digester:1.7" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: javax.mail:mail:1.4" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: org.jvnet.hudson:activation:1.1.1-hudson-1" level="project" />
@ -92,7 +101,6 @@
<orderEntry type="library" scope="PROVIDED" name="Maven: org.springframework:spring-dao:1.2.9" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: org.springframework:spring-context:2.5" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: org.codehaus.groovy:groovy-all:1.6.0" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: org.apache.ant:ant-launcher:1.7.1" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: jline:jline:0.9.94" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: org.springframework:spring-web:2.5" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: aopalliance:aopalliance:1.0" level="project" />

View File

@ -10,7 +10,7 @@
<groupId>net.masterthought.jenkins</groupId>
<artifactId>cucumber-reports</artifactId>
<version>1.0-SNAPSHOT</version>
<version>0.0.1</version>
<packaging>hpi</packaging>
<!-- get every artifact through repo.jenkins-ci.org, which proxies all the artifacts that we need -->

View File

@ -23,11 +23,13 @@ import java.io.IOException;
public class CucumberReportPublisher extends Recorder {
private final String jsonReportDirectory;
public final String jsonReportDirectory;
public final String pluginUrlPath;
@DataBoundConstructor
public CucumberReportPublisher(String jsonReportDirectory) {
public CucumberReportPublisher(String jsonReportDirectory, String pluginUrlPath) {
this.jsonReportDirectory = jsonReportDirectory;
this.pluginUrlPath = pluginUrlPath;
}
private String[] findJsonFiles(File targetDirectory) {
@ -65,7 +67,7 @@ public class CucumberReportPublisher extends Recorder {
String[] jsonReportFiles = findJsonFiles(targetBuildDirectory);
for (String file : jsonReportFiles) {
listener.getLogger().println("[CucumberReportPublisher] Generating HTML reports based on: " + file);
SingleResultParser singleResultParser = new SingleResultParser(new File(targetBuildDirectory, file).getAbsolutePath(), targetBuildDirectory, buildNumber, buildProject);
SingleResultParser singleResultParser = new SingleResultParser(new File(targetBuildDirectory, file).getAbsolutePath(), targetBuildDirectory, pluginUrlPath, buildNumber, buildProject);
try {
singleResultParser.generateReports();
} catch (Exception e) {

View File

@ -20,13 +20,15 @@ public class SingleResultParser {
private String buildNumber;
private String buildProject;
private List<Util.Status> totalSteps;
private String pluginUrlPath;
public SingleResultParser(String jsonResultFile, File reportDirectory, String buildNumber, String buildProject) throws IOException {
public SingleResultParser(String jsonResultFile, File reportDirectory, String pluginUrlPath, String buildNumber, String buildProject) throws IOException {
this.featureList = parseJson(jsonResultFile);
this.totalSteps = getAllStepStatuses();
this.reportDirectory = reportDirectory;
this.buildNumber = buildNumber;
this.buildProject = buildProject;
this.pluginUrlPath = getPluginUrlPath(pluginUrlPath);
}
public void generateReports() throws Exception {
@ -50,10 +52,32 @@ public class SingleResultParser {
context.put("total_skipped", getTotalSkipped());
context.put("chart_data", XmlChartBuilder.donutChart(getTotalPasses(), getTotalFails(), getTotalSkipped()));
context.put("time_stamp", timeStamp());
context.put("jenkins_base", pluginUrlPath);
generateReport("feature-overview.html", featureOverview, context);
}
public void generateFeatureReports() throws Exception {
for (Feature feature : featureList) {
VelocityEngine ve = new VelocityEngine();
ve.init(getProperties());
Template featureResult = ve.getTemplate("templates/featureReport.vm");
VelocityContext context = new VelocityContext();
context.put("feature", feature);
context.put("report_status_colour", getReportStatusColour(feature));
context.put("build_project", buildProject);
context.put("build_number", buildNumber);
context.put("scenarios", feature.getElements());
context.put("time_stamp", timeStamp());
context.put("jenkins_base", pluginUrlPath);
generateReport(feature.getFileName(), featureResult, context);
}
}
private String getPluginUrlPath(String path){
return path.isEmpty() ? "/" : path;
}
private int getTotalSteps() {
return totalSteps.size();
}
@ -94,22 +118,6 @@ public class SingleResultParser {
return scenarios;
}
public void generateFeatureReports() throws Exception {
for (Feature feature : featureList) {
VelocityEngine ve = new VelocityEngine();
ve.init(getProperties());
Template featureResult = ve.getTemplate("templates/featureReport.vm");
VelocityContext context = new VelocityContext();
context.put("feature", feature);
context.put("report_status_colour", getReportStatusColour(feature));
context.put("build_project", buildProject);
context.put("build_number", buildNumber);
context.put("scenarios", feature.getElements());
context.put("time_stamp", timeStamp());
generateReport(feature.getFileName(), featureResult, context);
}
}
private void generateReport(String fileName, Template featureResult, VelocityContext context) throws Exception {
Writer writer = new FileWriter(new File(reportDirectory, fileName));
featureResult.merge(context, writer);

View File

@ -11,6 +11,9 @@
-->
<f:entry title="Json Reports Path" field="jsonReportDirectory" description="The path relative to the workspace of the json reports generated by cucumber-jvm e.g. target/cucumber">
<f:textbox />
</f:entry>
<f:entry title="Plugin Url Path" field="pluginUrlPath" description="The path to the jenkins user content url e.g. http://host:port[/jenkins/]plugin - leave empty if jenkins url root is host:port">
<f:textbox />
</f:entry>
</j:jelly>

View File

@ -3,7 +3,7 @@
<head>
<script language="javascript">AC_FL_RunContent = 0;</script>
<script language="javascript"> DetectFlashVer = 0; </script>
<script src="/plugin/cucumber-reports/charts/AC_RunActiveContent.js" language="javascript"></script>
<script src="${jenkins_base}plugin/cucumber-reports/charts/AC_RunActiveContent.js" language="javascript"></script>
<script language="JavaScript" type="text/javascript">
<!--
var requiredMajorVersion = 10;
@ -13,12 +13,12 @@ var requiredRevision = 45;
</script>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>Cucumber-JVM Html Reports - Feature Overview</title>
<link rel="stylesheet" href="/plugin/cucumber-reports/blue/css/style.css" type="text/css" media="screen" />
<link rel="stylesheet" href="/plugin/cucumber-reports/blue/css/skin/style.css" type="text/css" media="screen" />
<link rel="stylesheet" href="/plugin/cucumber-reports/blue/css/960.css" type="text/css" media="screen" />
<link rel="stylesheet" href="/plugin/cucumber-reports/blue/css/reset.css" type="text/css" media="screen" />
<link rel="stylesheet" href="/plugin/cucumber-reports/blue/css/text.css" type="text/css" media="screen" />
<link rel="shortcut icon" href="/plugin/cucumber-reports/blue/favicon.ico" />
<link rel="stylesheet" href="${jenkins_base}plugin/cucumber-reports/blue/css/style.css" type="text/css" media="screen" />
<link rel="stylesheet" href="${jenkins_base}plugin/cucumber-reports/blue/css/skin/style.css" type="text/css" media="screen" />
<link rel="stylesheet" href="${jenkins_base}plugin/cucumber-reports/blue/css/960.css" type="text/css" media="screen" />
<link rel="stylesheet" href="${jenkins_base}plugin/cucumber-reports/blue/css/reset.css" type="text/css" media="screen" />
<link rel="stylesheet" href="${jenkins_base}plugin/cucumber-reports/blue/css/text.css" type="text/css" media="screen" />
<link rel="shortcut icon" href="${jenkins_base}plugin/cucumber-reports/blue/favicon.ico" />
<style>
.feature-keyword{font-weight:bold;}
.feature-description{padding-left:15px;font-style:italic;background-color:beige;}
@ -71,7 +71,7 @@ table.stats-table td {
<h1 class="grid_4 logo"><a href="feature-overview.html" class='ie6fix'>Cucumber</a></h1>
<div class="grid_6" id="nav">
<ul>
<li><a href="/job/$build_project/$build_number">Back To Jenkins</a></li>
<li><a href="${jenkins_base}job/$build_project/$build_number">Back To Jenkins</a></li>
</ul>
</div>
</div>
@ -102,9 +102,9 @@ if (AC_FL_RunContent == 0 || DetectFlashVer == 0) {
'salign', 'TL',
'bgcolor', '#bbccff',
'wmode', 'opaque',
'movie', '/plugin/cucumber-reports/charts/charts',
'src', '/plugin/cucumber-reports/charts/charts',
'FlashVars', "library_path=/plugin/cucumber-reports/charts/charts_library&xml_data=$chart_data",
'movie', '${jenkins_base}plugin/cucumber-reports/charts/charts',
'src', '${jenkins_base}plugin/cucumber-reports/charts/charts',
'FlashVars', "library_path=${jenkins_base}plugin/cucumber-reports/charts/charts_library&xml_data=$chart_data",
'id', 'my_chart',
'name', 'my_chart',
'menu', 'true',

View File

@ -3,12 +3,12 @@
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>Cucumber-JVM Html Reports - Feature: $feature.getRawName() </title>
<link rel="stylesheet" href="/plugin/cucumber-reports/blue/css/style.css" type="text/css" media="screen" />
<link rel="stylesheet" href="/plugin/cucumber-reports/blue/css/skin/style.css" type="text/css" media="screen" />
<link rel="stylesheet" href="/plugin/cucumber-reports/blue/css/960.css" type="text/css" media="screen" />
<link rel="stylesheet" href="/plugin/cucumber-reports/blue/css/reset.css" type="text/css" media="screen" />
<link rel="stylesheet" href="/plugin/cucumber-reports/blue/css/text.css" type="text/css" media="screen" />
<link rel="shortcut icon" href="/plugin/cucumber-reports/blue/favicon.ico" />
<link rel="stylesheet" href="${jenkins_base}plugin/cucumber-reports/blue/css/style.css" type="text/css" media="screen" />
<link rel="stylesheet" href="${jenkins_base}plugin/cucumber-reports/blue/css/skin/style.css" type="text/css" media="screen" />
<link rel="stylesheet" href="${jenkins_base}plugin/cucumber-reports/blue/css/960.css" type="text/css" media="screen" />
<link rel="stylesheet" href="${jenkins_base}plugin/cucumber-reports/blue/css/reset.css" type="text/css" media="screen" />
<link rel="stylesheet" href="${jenkins_base}plugin/cucumber-reports/blue/css/text.css" type="text/css" media="screen" />
<link rel="shortcut icon" href="${jenkins_base}plugin/cucumber-reports/blue/favicon.ico" />
<style>
.feature-keyword{font-weight:bold;}
.feature-description{padding-left:15px;font-style:italic;background-color:beige;}
@ -61,7 +61,7 @@ background-color: white;
<h1 class="grid_4 logo"><a href="feature-overview.html" class='ie6fix'>Cucumber</a></h1>
<div class="grid_6" id="nav">
<ul>
<li><a href="/job/$build_project/$build_number">Back To Jenkins</a></li>
<li><a href="${jenkins_base}job/$build_project/$build_number">Back To Jenkins</a></li>
<li><a href="feature-overview.html">Back To Overview</a></li>
</ul>
</div>