Search in sources :

Example 1 with BuildAction

use of org.evosuite.jenkins.actions.BuildAction in project evosuite by EvoSuite.

the class EvoSuiteRecorder method perform.

@Override
public boolean perform(AbstractBuild<?, ?> build, Launcher launcher, BuildListener listener) throws InterruptedException, IOException {
    if (build.getResult().isWorseThan(Result.SUCCESS)) {
        listener.getLogger().println(EvoSuiteRecorder.LOG_PREFIX + "Build did not succeed, so no test case generation by EvoSuite will occur.");
        return true;
    }
    AbstractMavenProject<?, ?> project = ((AbstractMavenProject<?, ?>) build.getProject());
    ProjectAction projectAction = new ProjectAction(project);
    projectAction.perform(project, build, listener);
    BuildAction build_action = new BuildAction(build, projectAction);
    build.addAction(build_action);
    if (this.disableAutoCommit) {
        return true;
    }
    SCM scm = project.getScm();
    if (scm == null) {
        listener.getLogger().println(EvoSuiteRecorder.LOG_PREFIX + "Project '" + project.getName() + "' has no Source-Control-Management (SCM) defined.");
        return true;
    }
    org.evosuite.jenkins.scm.SCM scmWrapper = null;
    if (scm instanceof MercurialSCM) {
        scmWrapper = new Mercurial((MercurialSCM) scm, project, build, launcher, listener);
    } else if (scm instanceof GitSCM) {
        scmWrapper = new Git((GitSCM) scm, build, listener);
    } else {
        listener.getLogger().println(EvoSuiteRecorder.LOG_PREFIX + "SCM of type " + scm.getType() + " not supported!");
        return true;
    }
    assert scmWrapper != null;
    // perform commit action
    int number_of_files_committed = scmWrapper.commit(project, build, listener, this.branchName, this.ctgBestsDir);
    if (number_of_files_committed == -1) {
        return false;
    }
    if (!this.disableAutoPush && number_of_files_committed > 0) {
        if (!scmWrapper.push(build, listener, this.branchName)) {
            return false;
        }
    }
    return true;
}
Also used : Git(org.evosuite.jenkins.scm.Git) ProjectAction(org.evosuite.jenkins.actions.ProjectAction) MercurialSCM(hudson.plugins.mercurial.MercurialSCM) Mercurial(org.evosuite.jenkins.scm.Mercurial) GitSCM(hudson.plugins.git.GitSCM) MercurialSCM(hudson.plugins.mercurial.MercurialSCM) SCM(hudson.scm.SCM) BuildAction(org.evosuite.jenkins.actions.BuildAction) GitSCM(hudson.plugins.git.GitSCM)

Example 2 with BuildAction

use of org.evosuite.jenkins.actions.BuildAction in project evosuite by EvoSuite.

the class TimePlot method doStats.

private CategoryDataset doStats() {
    DataSetBuilder<String, ChartUtil.NumberOnlyBuildLabel> timeDataSetBuilder = new DataSetBuilder<String, ChartUtil.NumberOnlyBuildLabel>();
    for (Run<?, ?> build : this.project.getProject().getBuilds()) {
        final BuildAction build_action = build.getAction(BuildAction.class);
        if (build_action == null) {
            // no build action is associated with this build, so skip it
            continue;
        }
        int timeBudget = build_action.getProjectAction().getTimeBudget();
        timeDataSetBuilder.add(timeBudget, "Total Time Budget", new ChartUtil.NumberOnlyBuildLabel(build));
        int totalEffort = build_action.getProjectAction().getTotalEffort();
        timeDataSetBuilder.add(totalEffort, "Time Budget Used", new ChartUtil.NumberOnlyBuildLabel(build));
    }
    return timeDataSetBuilder.build();
}
Also used : ChartUtil(hudson.util.ChartUtil) DataSetBuilder(hudson.util.DataSetBuilder) BuildAction(org.evosuite.jenkins.actions.BuildAction)

Example 3 with BuildAction

use of org.evosuite.jenkins.actions.BuildAction in project evosuite by EvoSuite.

the class CoveragePlot method doStats.

private CategoryDataset doStats() {
    DataSetBuilder<String, ChartUtil.NumberOnlyBuildLabel> coverageDataSetBuilder = new DataSetBuilder<String, ChartUtil.NumberOnlyBuildLabel>();
    for (Run<?, ?> build : this.project.getProject().getBuilds()) {
        final BuildAction build_action = build.getAction(BuildAction.class);
        if (build_action == null) {
            // no build action is associated with this build, so skip it
            continue;
        }
        Set<String> criteria = build_action.getProjectAction().getCriteria();
        for (String criterion : criteria) {
            double coverage = build_action.getProjectAction().getCriterionCoverage(criterion);
            coverageDataSetBuilder.add(coverage, criterion, new ChartUtil.NumberOnlyBuildLabel(build));
        }
    }
    return coverageDataSetBuilder.build();
}
Also used : ChartUtil(hudson.util.ChartUtil) DataSetBuilder(hudson.util.DataSetBuilder) BuildAction(org.evosuite.jenkins.actions.BuildAction)

Aggregations

BuildAction (org.evosuite.jenkins.actions.BuildAction)3 ChartUtil (hudson.util.ChartUtil)2 DataSetBuilder (hudson.util.DataSetBuilder)2 GitSCM (hudson.plugins.git.GitSCM)1 MercurialSCM (hudson.plugins.mercurial.MercurialSCM)1 SCM (hudson.scm.SCM)1 ProjectAction (org.evosuite.jenkins.actions.ProjectAction)1 Git (org.evosuite.jenkins.scm.Git)1 Mercurial (org.evosuite.jenkins.scm.Mercurial)1