Search in sources :

Example 6 with DownstreamPassCondition

use of hudson.plugins.promoted_builds.conditions.DownstreamPassCondition in project promoted-builds-plugin by jenkinsci.

the class KeepBuildForeverActionTest method createDownstreamSuccessPromotion.

private PromotionProcess createDownstreamSuccessPromotion(FreeStyleProject upStream, FreeStyleProject downStream) throws Descriptor.FormException, IOException {
    JobPropertyImpl promotionProperty = new JobPropertyImpl(upStream);
    upStream.addProperty(promotionProperty);
    PromotionProcess promotionJob = promotionProperty.addProcess("promotion");
    promotionJob.conditions.add(new DownstreamPassCondition(downStream.getName()));
    return promotionJob;
}
Also used : DownstreamPassCondition(hudson.plugins.promoted_builds.conditions.DownstreamPassCondition)

Example 7 with DownstreamPassCondition

use of hudson.plugins.promoted_builds.conditions.DownstreamPassCondition in project promoted-builds-plugin by jenkinsci.

the class PromotionProcessTest method testPromotionWithoutFingerprint.

/**
 * Tests a promotion induced by the pseudo upstream/downstream cause relationship
 */
@Test
public void testPromotionWithoutFingerprint() throws Exception {
    FreeStyleProject up = j.createFreeStyleProject("up");
    FreeStyleProject down = j.createFreeStyleProject();
    // promote if the downstream passes
    JobPropertyImpl promotion = new JobPropertyImpl(up);
    up.addProperty(promotion);
    PromotionProcess proc = promotion.addProcess("promo");
    proc.conditions.add(new DownstreamPassCondition(down.getName()));
    // trigger downstream automatically to create relationship
    up.getPublishersList().add(new BuildTrigger(down.getName(), Result.SUCCESS));
    j.jenkins.rebuildDependencyGraph();
    // this is the downstream job
    down.getBuildersList().add(Functions.isWindows() ? new BatchFile("set /a \"exitCode=BUILD_NUMBER%%2\"\r\n" + "exit /b %exitCode%\r\n") : // expr exits with non-zero status if result is zero
    new Shell("expr $BUILD_NUMBER % 2 - 1\n"));
    // not yet promoted while the downstream is failing
    FreeStyleBuild up1 = j.assertBuildStatusSuccess(up.scheduleBuild2(0).get());
    waitForCompletion(down, 1);
    assertEquals(0, proc.getBuilds().size());
    // do it one more time and this time it should work
    FreeStyleBuild up2 = j.assertBuildStatusSuccess(up.scheduleBuild2(0).get());
    waitForCompletion(down, 2);
    assertEquals(1, proc.getBuilds().size());
    {
        // verify that it promoted the right stuff
        Promotion pb = proc.getBuilds().get(0);
        assertSame(pb.getTargetBuildOrFail(), up2);
        PromotedBuildAction badge = (PromotedBuildAction) up2.getBadgeActions().get(0);
        assertTrue(badge.contains(proc));
    }
}
Also used : BatchFile(hudson.tasks.BatchFile) Shell(hudson.tasks.Shell) DownstreamPassCondition(hudson.plugins.promoted_builds.conditions.DownstreamPassCondition) BuildTrigger(hudson.tasks.BuildTrigger) FreeStyleBuild(hudson.model.FreeStyleBuild) FreeStyleProject(hudson.model.FreeStyleProject) Test(org.junit.Test)

Example 8 with DownstreamPassCondition

use of hudson.plugins.promoted_builds.conditions.DownstreamPassCondition in project promoted-builds-plugin by jenkinsci.

the class PromotionContext method conditions.

public void conditions(Closure<?> conditionClosure) {
    // delegate to ConditionsContext
    ConditionsContext conditionContext = new ConditionsContext(dslEnvironment);
    executeInContext(conditionClosure, conditionContext);
    if (conditionContext.isSelfPromotion()) {
        conditions.add(new SelfPromotionCondition(conditionContext.isEvenIfUnstable()));
    }
    if (conditionContext.isParameterizedSelfPromotion()) {
        conditions.add(new ParameterizedSelfPromotionCondition(conditionContext.isEvenIfUnstableParameterized(), conditionContext.getParameterName(), conditionContext.getParameterValue()));
    }
    if (conditionContext.isManual()) {
        JobDslManualCondition condition = new JobDslManualCondition();
        condition.setUsers(conditionContext.getUsers());
        if (conditionContext.getParams() != null) {
            condition.setParameterDefinitionNodes(conditionContext.getParams().values());
        }
        conditions.add(condition);
    }
    if (conditionContext.isReleaseBuild()) {
        conditions.add(new ReleasePromotionCondition());
    }
    if (conditionContext.isDownstreamPass()) {
        conditions.add(new DownstreamPassCondition(conditionContext.getJobs(), conditionContext.isEvenIfUnstableDownstream()));
    }
    if (conditionContext.isUpstreamPromotion()) {
        conditions.add(new UpstreamPromotionCondition(conditionContext.getPromotionNames()));
    }
}
Also used : DownstreamPassCondition(hudson.plugins.promoted_builds.conditions.DownstreamPassCondition) UpstreamPromotionCondition(hudson.plugins.promoted_builds.conditions.UpstreamPromotionCondition) ParameterizedSelfPromotionCondition(hudson.plugins.promoted_builds.conditions.ParameterizedSelfPromotionCondition) SelfPromotionCondition(hudson.plugins.promoted_builds.conditions.SelfPromotionCondition) ParameterizedSelfPromotionCondition(hudson.plugins.promoted_builds.conditions.ParameterizedSelfPromotionCondition)

Aggregations

DownstreamPassCondition (hudson.plugins.promoted_builds.conditions.DownstreamPassCondition)8 Test (org.junit.Test)6 FreeStyleProject (hudson.model.FreeStyleProject)5 JavadocArchiver (hudson.tasks.JavadocArchiver)3 Issue (org.jvnet.hudson.test.Issue)3 JenkinsRule (org.jvnet.hudson.test.JenkinsRule)3 HtmlPage (com.gargoylesoftware.htmlunit.html.HtmlPage)2 FreeStyleBuild (hudson.model.FreeStyleBuild)2 BatchFile (hudson.tasks.BatchFile)2 BuildTrigger (hudson.tasks.BuildTrigger)2 Shell (hudson.tasks.Shell)2 InheritanceBuild (hudson.plugins.project_inheritance.projects.InheritanceBuild)1 JobPropertyImpl (hudson.plugins.promoted_builds.JobPropertyImpl)1 PromotedBuildAction (hudson.plugins.promoted_builds.PromotedBuildAction)1 PromotionProcess (hudson.plugins.promoted_builds.PromotionProcess)1 Status (hudson.plugins.promoted_builds.Status)1 ParameterizedSelfPromotionCondition (hudson.plugins.promoted_builds.conditions.ParameterizedSelfPromotionCondition)1 SelfPromotionCondition (hudson.plugins.promoted_builds.conditions.SelfPromotionCondition)1 UpstreamPromotionCondition (hudson.plugins.promoted_builds.conditions.UpstreamPromotionCondition)1 InheritanceProjectsPair (hudson.plugins.promoted_builds.inheritance.helpers.InheritanceProjectsPair)1