diff --git a/src/main/java/hudson/plugins/jacoco/JacocoBuildAction.java b/src/main/java/hudson/plugins/jacoco/JacocoBuildAction.java index 7d5adb94..9e472245 100644 --- a/src/main/java/hudson/plugins/jacoco/JacocoBuildAction.java +++ b/src/main/java/hudson/plugins/jacoco/JacocoBuildAction.java @@ -240,6 +240,37 @@ public JacocoBuildAction getPreviousResult() { return getPreviousResult(owner); } + /** + * @return Map to represents coverage objects and its status to show on build status page (summary.jelly). + */ + public Map getCoverageRatios(){ + CoverageReport result = getResult(); + Map ratios = new LinkedHashMap(); + if( result != null ) { + Coverage instructionCoverage = result.getInstructionCoverage(); + Coverage classCoverage = result.getClassCoverage(); + Coverage complexityScore = result.getComplexityScore(); + Coverage branchCoverage = result.getBranchCoverage(); + Coverage lineCoverage = result.getLineCoverage(); + Coverage methodCoverage = result.getMethodCoverage(); + + instructionCoverage.setType(CoverageElement.Type.INSTRUCTION); + classCoverage.setType(CoverageElement.Type.CLASS); + complexityScore.setType(CoverageElement.Type.COMPLEXITY); + branchCoverage.setType(CoverageElement.Type.BRANCH); + lineCoverage.setType(CoverageElement.Type.LINE); + methodCoverage.setType(CoverageElement.Type.METHOD); + + ratios.put(instructionCoverage,JacocoHealthReportThresholds.RESULT.BELLOWMINIMUM == thresholds.getResultByTypeAndRatio(instructionCoverage)); + ratios.put(branchCoverage,JacocoHealthReportThresholds.RESULT.BELLOWMINIMUM == thresholds.getResultByTypeAndRatio(branchCoverage)); + ratios.put(complexityScore,JacocoHealthReportThresholds.RESULT.BELLOWMINIMUM == thresholds.getResultByTypeAndRatio(complexityScore)); + ratios.put(lineCoverage,JacocoHealthReportThresholds.RESULT.BELLOWMINIMUM == thresholds.getResultByTypeAndRatio(lineCoverage)); + ratios.put(methodCoverage,JacocoHealthReportThresholds.RESULT.BELLOWMINIMUM == thresholds.getResultByTypeAndRatio(methodCoverage)); + ratios.put(classCoverage,JacocoHealthReportThresholds.RESULT.BELLOWMINIMUM == thresholds.getResultByTypeAndRatio(classCoverage)); + } + return ratios; + } + /** * Gets the previous {@link JacocoBuildAction} of the given build. */ diff --git a/src/main/resources/hudson/plugins/jacoco/JacocoBuildAction/summary.jelly b/src/main/resources/hudson/plugins/jacoco/JacocoBuildAction/summary.jelly new file mode 100644 index 00000000..fa55433d --- /dev/null +++ b/src/main/resources/hudson/plugins/jacoco/JacocoBuildAction/summary.jelly @@ -0,0 +1,17 @@ + + + + Jacoco - ${%Overall Coverage Summary} + + + + + + + + +
${coverageRatio.key.type}${coverageRatio.key.percentage}%
+
+
\ No newline at end of file diff --git a/src/main/webapp/icons/jacoco-48x48.png b/src/main/webapp/icons/jacoco-48x48.png new file mode 100644 index 00000000..c281a43b Binary files /dev/null and b/src/main/webapp/icons/jacoco-48x48.png differ