Search in sources :

Example 1 with ViolationsBuildAction

use of hudson.plugins.violations.ViolationsBuildAction in project violations-plugin by jenkinsci.

the class ViolationsMavenReporter method getCreateBuildAction.

private ViolationsBuildAction getCreateBuildAction(MavenBuild build) {
    ViolationsBuildAction ret = build.getAction(ViolationsBuildAction.class);
    if (ret == null) {
        ret = new ViolationsBuildAction(build);
        build.getActions().add(ret);
    }
    return ret;
}
Also used : ViolationsBuildAction(hudson.plugins.violations.ViolationsBuildAction)

Example 2 with ViolationsBuildAction

use of hudson.plugins.violations.ViolationsBuildAction 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 3 with ViolationsBuildAction

use of hudson.plugins.violations.ViolationsBuildAction in project violations-plugin by jenkinsci.

the class ViolationsAggregatedReport method init.

private void init() {
    for (MavenBuild b : mavenBuild.getModuleLastBuilds().values()) {
        ViolationsBuildAction a = b.getAction(ViolationsBuildAction.class);
        if (a == null || a.getReport() == null) {
            continue;
        }
        ViolationsModuleReport r = new ViolationsModuleReport(b, a.getReport());
        reports.add(r);
        HealthReport x = a.getReport().getBuildHealth();
        HealthReport aReport = null;
        if (x != null) {
            aReport = new HealthReport(x.getScore(), Messages._ViolationsAggregatedReport_HealthDescription(x.getDescription(), r.getDisplayName()));
        }
        if (aReport != null) {
            healthReport = HealthReport.min(healthReport, aReport);
        }
        setConfig(a.getReport().getConfig());
        Map<String, Integer> aggregatedViolations = getViolations();
        for (Map.Entry<String, Integer> e : a.getReport().getViolations().entrySet()) {
            int val = e.getValue();
            Integer current = aggregatedViolations.get(e.getKey());
            if (current == null) {
                aggregatedViolations.put(e.getKey(), e.getValue());
            } else {
                aggregatedViolations.put(e.getKey(), val + current);
            }
        }
    }
}
Also used : MavenBuild(hudson.maven.MavenBuild) ViolationsBuildAction(hudson.plugins.violations.ViolationsBuildAction) HealthReport(hudson.model.HealthReport) Map(java.util.Map)

Aggregations

ViolationsBuildAction (hudson.plugins.violations.ViolationsBuildAction)3 FilePath (hudson.FilePath)1 MavenBuild (hudson.maven.MavenBuild)1 MavenModuleSetBuild (hudson.maven.MavenModuleSetBuild)1 HealthReport (hudson.model.HealthReport)1 ViolationsCollector (hudson.plugins.violations.ViolationsCollector)1 ViolationsReport (hudson.plugins.violations.ViolationsReport)1 File (java.io.File)1 IOException (java.io.IOException)1 Map (java.util.Map)1