Search in sources :

Example 6 with InheritanceBuild

use of hudson.plugins.project_inheritance.projects.InheritanceBuild in project promoted-builds-plugin by jenkinsci.

the class SelfPromotionInheritanceTest method testUnstable.

@Test
public void testUnstable() throws Exception {
    InheritanceProjectsPair inheritanceProjectPair = j.createInheritanceProjectDerivedWithBase();
    // promote if the downstream passes
    JobPropertyImpl promotion = new JobPropertyImpl(inheritanceProjectPair.getBase());
    inheritanceProjectPair.getBase().addProperty(promotion);
    PromotionProcess promo1 = promotion.addProcess("promo1");
    promo1.conditions.add(new SelfPromotionCondition(false));
    PromotionProcess promo2 = promotion.addProcess("promo2");
    promo2.conditions.add(new SelfPromotionCondition(true));
    inheritanceProjectPair.getDerived().getBuildersList().add(unstableBuilder());
    InheritanceBuild b = j.assertBuildStatus(Result.UNSTABLE, inheritanceProjectPair.getDerived().scheduleBuild2(0).get());
    j.waitUntilNoActivity();
    // rebind
    promotion = inheritanceProjectPair.getDerived().getProperty(JobPropertyImpl.class, /*Forcing inheritance as temporary hack for inheritance plugin 1.53 
                because that version of the plugin uses inheritance only for certain predefined cases: 
                -specific methods on the call stack
                -url paths.
                This has been changed as pull request https://github.com/i-m-c/jenkins-inheritance-plugin/pull/40
               */
    IMode.INHERIT_FORCED);
    promo1 = promotion.getItem("promo1");
    promo2 = promotion.getItem("promo2");
    // internally, the promotion is still an asynchronous process. It just happens
    // right away after the build is complete.
    // verify that only one promotions happened
    assertTrue(promo1.getBuilds().isEmpty());
    Promotion pb = promo2.getBuilds().get(0);
    assertSame(pb.getTarget(), b);
    PromotedBuildAction badge = (PromotedBuildAction) b.getBadgeActions().get(0);
    assertFalse(badge.contains(promo1));
    assertTrue(badge.contains(promo2));
}
Also used : InheritanceProjectsPair(hudson.plugins.promoted_builds.inheritance.helpers.InheritanceProjectsPair) InheritanceBuild(hudson.plugins.project_inheritance.projects.InheritanceBuild) PromotionProcess(hudson.plugins.promoted_builds.PromotionProcess) SelfPromotionCondition(hudson.plugins.promoted_builds.conditions.SelfPromotionCondition) PromotedBuildAction(hudson.plugins.promoted_builds.PromotedBuildAction) JobPropertyImpl(hudson.plugins.promoted_builds.JobPropertyImpl) Promotion(hudson.plugins.promoted_builds.Promotion) Test(org.junit.Test)

Aggregations

InheritanceBuild (hudson.plugins.project_inheritance.projects.InheritanceBuild)6 JobPropertyImpl (hudson.plugins.promoted_builds.JobPropertyImpl)6 PromotedBuildAction (hudson.plugins.promoted_builds.PromotedBuildAction)6 PromotionProcess (hudson.plugins.promoted_builds.PromotionProcess)6 InheritanceProjectsPair (hudson.plugins.promoted_builds.inheritance.helpers.InheritanceProjectsPair)6 Test (org.junit.Test)6 Promotion (hudson.plugins.promoted_builds.Promotion)3 SelfPromotionCondition (hudson.plugins.promoted_builds.conditions.SelfPromotionCondition)3 Descriptor (hudson.model.Descriptor)2 StringParameterDefinition (hudson.model.StringParameterDefinition)2 ManualCondition (hudson.plugins.promoted_builds.conditions.ManualCondition)2 ManualApproval (hudson.plugins.promoted_builds.conditions.ManualCondition.ManualApproval)2 HtmlElement (com.gargoylesoftware.htmlunit.html.HtmlElement)1 HtmlForm (com.gargoylesoftware.htmlunit.html.HtmlForm)1 HtmlPage (com.gargoylesoftware.htmlunit.html.HtmlPage)1 ParameterDefinition (hudson.model.ParameterDefinition)1 ParameterValue (hudson.model.ParameterValue)1 Status (hudson.plugins.promoted_builds.Status)1 DownstreamPassCondition (hudson.plugins.promoted_builds.conditions.DownstreamPassCondition)1 BuildTrigger (hudson.tasks.BuildTrigger)1