use of hudson.plugins.promoted_builds.Promotion in project promoted-builds-plugin by jenkinsci.
the class SelfPromotionTest method testBasic.
public void testBasic() throws Exception {
FreeStyleProject p = createFreeStyleProject();
// promote if the downstream passes
JobPropertyImpl promotion = new JobPropertyImpl(p);
p.addProperty(promotion);
PromotionProcess promo1 = promotion.addProcess("promo1");
promo1.conditions.add(new SelfPromotionCondition(false));
PromotionProcess promo2 = promotion.addProcess("promo2");
promo2.conditions.add(new SelfPromotionCondition(false));
// ensure that the data survives the roundtrip
configRoundtrip(p);
// rebind
promotion = p.getProperty(JobPropertyImpl.class);
promo1 = promotion.getItem("promo1");
promo2 = promotion.getItem("promo2");
FreeStyleBuild b = assertBuildStatusSuccess(p.scheduleBuild2(0));
// internally, the promotion is still an asynchronous process. It just happens
// right away after the build is complete.
Thread.sleep(1000);
// verify that both promotions happened
Promotion pb = promo1.getBuilds().get(0);
assertSame(pb.getTarget(), b);
pb = promo2.getBuilds().get(0);
assertSame(pb.getTarget(), b);
PromotedBuildAction badge = (PromotedBuildAction) b.getBadgeActions().get(0);
assertTrue(badge.contains(promo1));
assertTrue(badge.contains(promo2));
}
use of hudson.plugins.promoted_builds.Promotion in project promoted-builds-plugin by jenkinsci.
the class SelfPromotionTest method testPromotionEnvironmentShouldIncludeTargetParameters.
@Bug(22679)
public // @Bug(34826) // Can be reproduced in Jenkins 2.3 +
void testPromotionEnvironmentShouldIncludeTargetParameters() throws Exception {
String paramName = "param";
FreeStyleProject p = createFreeStyleProject();
p.addProperty(new ParametersDefinitionProperty(new StringParameterDefinition(paramName, "")));
// promote if the downstream passes
JobPropertyImpl promotion = new JobPropertyImpl(p);
p.addProperty(promotion);
PromotionProcess promo1 = promotion.addProcess("promo1");
promo1.conditions.add(new SelfPromotionCondition(false));
// ensure that the data survives the roundtrip
configRoundtrip(p);
// rebind
promotion = p.getProperty(JobPropertyImpl.class);
promo1 = promotion.getItem("promo1");
String paramValue = "someString";
FreeStyleBuild b = assertBuildStatusSuccess(p.scheduleBuild2(0, new Cause.UserCause(), new ParametersAction(new StringParameterValue(paramName, paramValue))));
// internally, the promotion is still an asynchronous process. It just happens
// right away after the build is complete.
Thread.sleep(1000);
// verify that the promotion's environment contains the parameter from the target build.
Promotion pb = promo1.getBuildByNumber(1);
assertEquals(paramValue, pb.getEnvironment(TaskListener.NULL).get(paramName, null));
}
Aggregations