use of hudson.plugins.promoted_builds.JobPropertyImpl in project promoted-builds-plugin by jenkinsci.
the class DownstreamPassConditionTest method shouldEvaluateUpstreamRecursively.
@Test
@Bug(7739)
public void shouldEvaluateUpstreamRecursively() throws Exception {
final FreeStyleProject job1 = j.createFreeStyleProject("job1");
final FreeStyleProject job2 = j.createFreeStyleProject("job2");
final FreeStyleProject job3 = j.createFreeStyleProject("job3");
final JobPropertyImpl property = new JobPropertyImpl(job1);
job1.addProperty(property);
final PromotionProcess process = property.addProcess("promotion");
process.conditions.add(new DownstreamPassCondition(job3.getFullName()));
job1.getPublishersList().add(new BuildTrigger(job2.getFullName(), Result.SUCCESS));
job2.getPublishersList().add(new BuildTrigger(job3.getFullName(), Result.SUCCESS));
j.jenkins.rebuildDependencyGraph();
final FreeStyleBuild run1 = j.buildAndAssertSuccess(job1);
j.waitUntilNoActivity();
j.assertBuildStatusSuccess(job2.getLastBuild());
j.waitUntilNoActivity();
final FreeStyleBuild run3 = j.assertBuildStatusSuccess(job3.getLastBuild());
j.waitUntilNoActivity();
assertEquals("fingerprint relation", run3.getUpstreamRelationship(job1), -1);
assertFalse("no promotion process", process.getBuilds().isEmpty());
final PromotedBuildAction action = run1.getAction(PromotedBuildAction.class);
assertNotNull("no promoted action", action);
final Status promotion = action.getPromotion("promotion");
assertNotNull("promotion not found", promotion);
assertTrue("promotion not successful", promotion.isPromotionSuccessful());
}
use of hudson.plugins.promoted_builds.JobPropertyImpl in project promoted-builds-plugin by jenkinsci.
the class GroovyConditionTest method testBinding.
@Test
public void testBinding() throws Exception {
FreeStyleProject p = j.createFreeStyleProject();
final JobPropertyImpl property = new JobPropertyImpl(p);
final PromotionProcess promotionProcess = property.addProcess("testPromotion");
promotionProcess.conditions.add(new GroovyCondition(new SecureGroovyScript("promotionProcess instanceof hudson.plugins.promoted_builds.PromotionProcess && " + "build instanceof hudson.model.AbstractBuild && " + "jenkins instanceof jenkins.model.Jenkins", false, null), "", ""));
p = j.configRoundtrip(p);
final FreeStyleBuild build = j.buildAndAssertSuccess(p);
Assert.assertNotNull("Promotion was expected", promotionProcess.isMet(build));
}
use of hudson.plugins.promoted_builds.JobPropertyImpl 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.plugins.promoted_builds.JobPropertyImpl 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.plugins.promoted_builds.JobPropertyImpl 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());
}
Aggregations