use of hudson.model.FreeStyleBuild in project promoted-builds-plugin by jenkinsci.
the class ManualConditionBug22005 method testPromotionProcess.
public void testPromotionProcess() throws Exception {
FreeStyleProject p = createFreeStyleProject();
ExtensionList<Descriptor> list = hudson.getExtensionList(Descriptor.class);
list.add(new JobPropertyImpl.DescriptorImpl(JobPropertyImpl.class));
JobPropertyImpl base = new JobPropertyImpl(p);
p.addProperty(base);
PromotionProcess prom0 = createPromotionProcess(base, "PROM0");
ManualCondition prom0Condition = prom0.conditions.get(ManualCondition.class);
PromotionProcess prom1 = createPromotionProcess(base, "PROM1");
ManualCondition prom1Condition = prom1.conditions.get(ManualCondition.class);
PromotionProcess prom2 = createPromotionProcess(base, "PROM2");
ManualCondition prom2Condition = prom2.conditions.get(ManualCondition.class);
FreeStyleBuild b1 = assertBuildStatusSuccess(p.scheduleBuild2(0));
Promotion p0b1 = assertBuildStatusSuccess(prom0Condition.approve(b1, prom0));
assertEquals(2, p0b1.getParameterValues().size());
assertEquals(2, p0b1.getParameterDefinitionsWithValue().size());
Promotion p1b1 = assertBuildStatusSuccess(prom1Condition.approve(b1, prom1));
assertEquals(2, p1b1.getParameterValues().size());
assertEquals(2, p1b1.getParameterDefinitionsWithValue().size());
Promotion p2b1 = assertBuildStatusSuccess(prom2Condition.approve(b1, prom2));
assertEquals(2, p2b1.getParameterValues().size());
assertEquals(2, p2b1.getParameterDefinitionsWithValue().size());
List<ManualApproval> approvals = b1.getActions(ManualApproval.class);
assertEquals(3, approvals.size());
PromotedBuildAction promBuildAction = b1.getAction(PromotedBuildAction.class);
List<Status> statuses = promBuildAction.getPromotions();
assertEquals(3, statuses.size());
for (Status status : statuses) {
Promotion lastBuild = status.getLast();
List<ParameterDefinition> lastBuildParameters = lastBuild.getParameterDefinitionsWithValue();
assertEquals(2, lastBuildParameters.size());
}
}
use of hudson.model.FreeStyleBuild in project promoted-builds-plugin by jenkinsci.
the class ManualConditionBug22005 method testPromotionProcessViaWebClient.
public void testPromotionProcessViaWebClient() throws Exception {
FreeStyleProject p = createFreeStyleProject();
ExtensionList<Descriptor> list = hudson.getExtensionList(Descriptor.class);
list.add(new JobPropertyImpl.DescriptorImpl(JobPropertyImpl.class));
JobPropertyImpl base = new JobPropertyImpl(p);
p.addProperty(base);
createPromotionProcess(base, "PROM0");
createPromotionProcess(base, "PROM1");
createPromotionProcess(base, "PROM2");
FreeStyleBuild b1 = assertBuildStatusSuccess(p.scheduleBuild2(0));
assertNull(b1.getAction(ManualApproval.class));
HtmlPage page = createWebClient().getPage(b1, "promotion");
//Approve Promotion
List<HtmlForm> forms = ManualConditionTest.getFormsByName(page, "approve");
assertFalse(forms.isEmpty());
assertEquals(3, forms.size());
for (HtmlForm form : forms) {
submit(form);
}
//reload promotions page
page = createWebClient().getPage(b1, "promotion");
forms = ManualConditionTest.getFormsByName(page, "build");
for (HtmlForm form : forms) {
List<HtmlElement> parameters = ManualConditionTest.getFormParameters(form);
assertEquals(2, parameters.size());
}
}
use of hudson.model.FreeStyleBuild in project promoted-builds-plugin by jenkinsci.
the class ManualConditionTest method testManualPromotionProcess.
public void testManualPromotionProcess() throws Exception {
FreeStyleProject p = createFreeStyleProject();
ExtensionList<Descriptor> list = hudson.getExtensionList(Descriptor.class);
list.add(new JobPropertyImpl.DescriptorImpl(JobPropertyImpl.class));
JobPropertyImpl base = new JobPropertyImpl(p);
p.addProperty(base);
PromotionProcess foo = base.addProcess("foo");
ManualCondition condition = new ManualCondition();
condition.getParameterDefinitions().add(new StringParameterDefinition("bogus_string_param_1", "bogus_value_1", "Bog parameter"));
condition.getParameterDefinitions().add(new StringParameterDefinition("bogus_string_param_2", "bogus_value_2", "Bog parameter"));
foo.conditions.add(condition);
FreeStyleBuild b1 = assertBuildStatusSuccess(p.scheduleBuild2(0));
// promote a build
List<ParameterValue> paramValues = condition.createDefaultValues();
//try to add duplicate values
paramValues.addAll(condition.createDefaultValues());
assertBuildStatusSuccess(condition.approve(b1, foo, paramValues));
ManualApproval manualApproval = b1.getAction(ManualApproval.class);
assertNotNull(manualApproval);
PromotedBuildAction statuses = b1.getAction(PromotedBuildAction.class);
assertNotNull(statuses);
assertNotNull(statuses.getPromotions());
assertFalse(statuses.getPromotions().isEmpty());
}
use of hudson.model.FreeStyleBuild in project promoted-builds-plugin by jenkinsci.
the class SelfPromotionTest method testUnstable.
public void testUnstable() 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(true));
// ensure that the data survives the roundtrip
configRoundtrip(p);
// rebind
promotion = p.getProperty(JobPropertyImpl.class);
promo1 = promotion.getItem("promo1");
promo2 = promotion.getItem("promo2");
p.getBuildersList().add(unstableBuilder());
FreeStyleBuild b = assertBuildStatus(Result.UNSTABLE, p.scheduleBuild2(0).get());
// internally, the promotion is still an asynchronous process. It just happens
// right away after the build is complete.
Thread.sleep(1000);
// 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));
}
use of hudson.model.FreeStyleBuild in project promoted-builds-plugin by jenkinsci.
the class KeepBuildForeverActionTest method testDoesNotCareAboutResultOfOriginalBuild.
public void testDoesNotCareAboutResultOfOriginalBuild() throws Exception {
FreeStyleProject upJob = createProject("up");
upJob.getBuildersList().add(new FixedResultBuilder(Result.FAILURE));
FreeStyleProject downJob = createProject("down");
downJob.getBuildersList().add(successfulBuilder());
PromotionProcess promotionJob = createDownstreamSuccessPromotion(upJob, downJob);
promotionJob.getBuildSteps().add(new KeepBuildForeverAction());
// fire ItemListeners, this includes ArtifactArchiver,Migrator to make this test compatible with jenkins 1.575+
fireItemListeners();
FreeStyleBuild upBuild = assertBuildStatus(Result.FAILURE, upJob.scheduleBuild2(0).get());
assertFalse(upBuild.isKeepLog());
assertBuildStatusSuccess(downJob.scheduleBuild2(0).get());
waitForBuild(promotionJob, 1);
assertTrue(upBuild.isKeepLog());
}
Aggregations