Search in sources :

Example 1 with ViolationsReport

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;
}
Also used : FilePath(hudson.FilePath) MavenModuleSetBuild(hudson.maven.MavenModuleSetBuild) ViolationsBuildAction(hudson.plugins.violations.ViolationsBuildAction) ViolationsReport(hudson.plugins.violations.ViolationsReport) IOException(java.io.IOException) File(java.io.File) ViolationsCollector(hudson.plugins.violations.ViolationsCollector)

Example 2 with ViolationsReport

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);
}
Also used : ChartUtil(hudson.util.ChartUtil) DataSetBuilder(hudson.util.DataSetBuilder) ViolationsReport(hudson.plugins.violations.ViolationsReport) Run(hudson.model.Run) SeverityTypeDataSet(hudson.plugins.violations.graph.SeverityTypeDataSet)

Example 3 with ViolationsReport

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();
}
Also used : NumberOnlyBuildLabel(hudson.util.ChartUtil.NumberOnlyBuildLabel) DataSetBuilder(hudson.util.DataSetBuilder) ViolationsReport(hudson.plugins.violations.ViolationsReport) Run(hudson.model.Run) TypeSummary(hudson.plugins.violations.TypeSummary)

Aggregations

ViolationsReport (hudson.plugins.violations.ViolationsReport)3 Run (hudson.model.Run)2 DataSetBuilder (hudson.util.DataSetBuilder)2 FilePath (hudson.FilePath)1 MavenModuleSetBuild (hudson.maven.MavenModuleSetBuild)1 TypeSummary (hudson.plugins.violations.TypeSummary)1 ViolationsBuildAction (hudson.plugins.violations.ViolationsBuildAction)1 ViolationsCollector (hudson.plugins.violations.ViolationsCollector)1 SeverityTypeDataSet (hudson.plugins.violations.graph.SeverityTypeDataSet)1 ChartUtil (hudson.util.ChartUtil)1 NumberOnlyBuildLabel (hudson.util.ChartUtil.NumberOnlyBuildLabel)1 File (java.io.File)1 IOException (java.io.IOException)1