use of hudson.plugins.violations.ViolationsReport in project violations-plugin by jenkinsci.
the class ViolationsMavenReporter method end.
@Override
public boolean end(MavenBuild build, Launcher launcher, BuildListener listener) throws InterruptedException, IOException {
registered = false;
FilePath htmlPath = new FilePath(new File(build.getProject().getRootDir(), VIOLATIONS));
FilePath targetPath = new FilePath(new File(build.getRootDir(), VIOLATIONS));
FilePath workspace = build.getWorkspace();
if (workspace == null) {
MavenModuleSetBuild parent = build.getModuleSetBuild();
throw new IOException("No workspace for " + build + "; parent workspace: " + (parent != null ? parent.getWorkspace() : "N/A") + "; builtOnStr=" + build.getBuiltOnStr() + "; builtOn=" + build.getBuiltOn());
}
ViolationsReport report = workspace.act(new ViolationsCollector(true, targetPath, htmlPath, config));
report.setConfig(config);
report.setBuild(build);
report.setBuildResult();
ViolationsBuildAction buildAction = getCreateBuildAction(build);
buildAction.setReport(report);
return true;
}
use of hudson.plugins.violations.ViolationsReport in project violations-plugin by jenkinsci.
the class AbstractViolationsBuildAction method doGraph.
/**
* This corresponds to the url ./graph.
*
* @param req
* the request parameters.
* @param rsp
* the response.
* @throws IOException
* if there is an error writing the graph
*/
public void doGraph(StaplerRequest req, StaplerResponse rsp) throws IOException {
String type = req.getParameter("type");
if (ChartUtil.awtProblemCause != null) {
// not available. send out error message
rsp.sendRedirect2(req.getContextPath() + "/images/headless.png");
return;
}
getBuild().getTimestamp();
if (!StringUtil.isBlank(type)) {
ChartUtil.generateGraph(req, rsp, new SeverityTypeDataSet(getReport(), type).createChart(), X_SIZE, Y_SIZE);
return;
}
DataSetBuilder<String, ChartUtil.NumberOnlyBuildLabel> dsb = new DataSetBuilder<String, ChartUtil.NumberOnlyBuildLabel>();
for (ViolationsReport r : ViolationsReport.iteration(getBuild())) {
for (String ty : r.getViolations().keySet()) {
dsb.add(roundUp(r.getViolations().get(ty)), ty, new ChartUtil.NumberOnlyBuildLabel((Run) r.getBuild()));
}
}
ChartUtil.generateGraph(req, rsp, createChart(dsb.build()), X_SIZE, Y_SIZE);
}
use of hudson.plugins.violations.ViolationsReport in project violations-plugin by jenkinsci.
the class SeverityTypeDataSet method buildDataSet.
/**
* Build the data set.
*
* @return the dataset.
*/
public CategoryDataset buildDataSet() {
DataSetBuilder<Row, NumberOnlyBuildLabel> builder = new DataSetBuilder<Row, NumberOnlyBuildLabel>();
for (ViolationsReport r = report; r != null; r = r.previous()) {
if (r.getTypeSummaries() == null) {
continue;
}
TypeSummary t = r.getTypeSummaries().get(type);
if (t == null) {
// Old report
continue;
}
if (t.getSeverityArray() == null || t.getSeverityArray().length != Severity.NUMBER_SEVERITIES) {
// Old report
continue;
}
int[] nums = t.getSeverityArray();
builder.add(nums[Severity.MEDIUM_VALUE] + nums[Severity.MEDIUM_HIGH_VALUE] + nums[Severity.MEDIUM_LOW_VALUE], MEDIUM_ROW, new NumberOnlyBuildLabel((Run) r.getBuild()));
builder.add(nums[Severity.HIGH_VALUE], HIGH_ROW, new NumberOnlyBuildLabel((Run) r.getBuild()));
builder.add(nums[Severity.LOW_VALUE], LOW_ROW, new NumberOnlyBuildLabel((Run) r.getBuild()));
}
return builder.build();
}
Aggregations