Search in sources :

Example 1 with Mercurial

use of org.evosuite.jenkins.scm.Mercurial 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)

Aggregations

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