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;
}
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));
}
}
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()));
}
}
Aggregations