Search in sources :

Example 6 with Result

use of hudson.model.Result in project hudson-2.x by hudson.

the class MatrixProjectTest method testGetTouchStoneResultConditionChildValue.

@Test
public void testGetTouchStoneResultConditionChildValue() throws IOException {
    Result parentResultCondition = Result.SUCCESS;
    Result childResultCondition = Result.FAILURE;
    MatrixProject parentProject = new MatrixProjectMock("parent");
    parentProject.setTouchStoneResultCondition(parentResultCondition);
    MatrixProject childProject1 = new MatrixProjectMock("child1");
    childProject1.setCascadingProject(parentProject);
    childProject1.setTouchStoneResultCondition(childResultCondition);
    assertEquals(childProject1.getTouchStoneResultCondition(), childResultCondition);
}
Also used : Result(hudson.model.Result) Test(org.junit.Test)

Example 7 with Result

use of hudson.model.Result in project blueocean-plugin by jenkinsci.

the class PipelineNodeTest method countBuilds.

private static int countBuilds(WorkflowJob job, Result status) {
    RunList<WorkflowRun> builds = job.getNewBuilds();
    Iterator<WorkflowRun> iterator = builds.iterator();
    int numBuilds = 0;
    while (iterator.hasNext()) {
        WorkflowRun build = iterator.next();
        Result buildRes = build.getResult();
        if (status == null || buildRes == status) {
            numBuilds++;
        }
    }
    return numBuilds;
}
Also used : WorkflowRun(org.jenkinsci.plugins.workflow.job.WorkflowRun) Result(hudson.model.Result)

Example 8 with Result

use of hudson.model.Result in project promoted-builds-plugin by jenkinsci.

the class DownstreamPassCondition method isMet.

@Override
public PromotionBadge isMet(PromotionProcess promotionProcess, AbstractBuild<?, ?> build) {
    Badge badge = new Badge();
    PseudoDownstreamBuilds pdb = build.getAction(PseudoDownstreamBuilds.class);
    EnvVars buildEnvironment = new EnvVars(build.getBuildVariables());
    OUTER: for (AbstractProject<?, ?> j : getJobList(build.getProject().getParent(), buildEnvironment)) {
        for (AbstractBuild<?, ?> b : build.getDownstreamBuilds(j)) {
            if (!b.isBuilding()) {
                Result r = b.getResult();
                if ((r == Result.SUCCESS) || (evenIfUnstable && r == Result.UNSTABLE)) {
                    badge.add(b);
                    continue OUTER;
                }
            }
        }
        if (pdb != null) {
            // if fingerprint doesn't have any, try the pseudo-downstream
            for (AbstractBuild<?, ?> b : pdb.listBuilds(j)) {
                if (!b.isBuilding()) {
                    Result r = b.getResult();
                    if ((r == Result.SUCCESS) || (evenIfUnstable && r == Result.UNSTABLE)) {
                        badge.add(b);
                        continue OUTER;
                    }
                }
            }
        }
        // none of the builds of this job passed.
        return null;
    }
    return badge;
}
Also used : EnvVars(hudson.EnvVars) AbstractBuild(hudson.model.AbstractBuild) PromotionBadge(hudson.plugins.promoted_builds.PromotionBadge) AbstractProject(hudson.model.AbstractProject) Result(hudson.model.Result)

Example 9 with Result

use of hudson.model.Result in project promoted-builds-plugin by jenkinsci.

the class KeepBuildForeverAction method perform.

@Override
public boolean perform(AbstractBuild<?, ?> build, Launcher launcher, BuildListener listener) throws InterruptedException, IOException {
    PrintStream console = listener.getLogger();
    // only applicable to promotions, so should be impossible not to be one, but check anyway
    if (!(build instanceof Promotion)) {
        console.println(Messages.KeepBuildForEverAction_console_notPromotion());
        build.setResult(Result.FAILURE);
        return false;
    }
    final Result buildResult = build.getResult();
    if (buildResult != null && buildResult.isWorseThan(PROMOTION_RESULT_MUST_BE_AT_LEAST)) {
        console.println(Messages.KeepBuildForEverAction_console_promotionNotGoodEnough(build.getResult()));
        return true;
    }
    AbstractBuild promoted = ((Promotion) build).getTarget();
    console.println(Messages.KeepBuildForEverAction_console_keepingBuild());
    promoted.keepLog();
    return true;
}
Also used : PrintStream(java.io.PrintStream) AbstractBuild(hudson.model.AbstractBuild) Result(hudson.model.Result)

Aggregations

Result (hudson.model.Result)9 Test (org.junit.Test)5 AbstractBuild (hudson.model.AbstractBuild)2 EnvVars (hudson.EnvVars)1 AbstractProject (hudson.model.AbstractProject)1 PromotionBadge (hudson.plugins.promoted_builds.PromotionBadge)1 File (java.io.File)1 IOException (java.io.IOException)1 PrintStream (java.io.PrintStream)1 WorkflowRun (org.jenkinsci.plugins.workflow.job.WorkflowRun)1