use of hudson.model.FreeStyleBuild in project promoted-builds-plugin by jenkinsci.
the class KeepBuildForeverActionTest method testDoesNotMarkBuildIfPromotionNotGoodEnough.
public void testDoesNotMarkBuildIfPromotionNotGoodEnough() throws Exception {
FreeStyleProject upJob = createProject("up");
upJob.getBuildersList().add(successfulBuilder());
FreeStyleProject downJob = createProject("down");
downJob.getBuildersList().add(successfulBuilder());
PromotionProcess promotionJob = createDownstreamSuccessPromotion(upJob, downJob);
promotionJob.getBuildSteps().add(new FixedResultBuilder(Result.FAILURE));
promotionJob.getBuildSteps().add(new KeepBuildForeverAction());
// fire ItemListeners, this includes ArtifactArchiver,Migrator to make this test compatible with jenkins 1.575+
fireItemListeners();
FreeStyleBuild upBuild = assertBuildStatusSuccess(upJob.scheduleBuild2(0).get());
assertFalse(upBuild.isKeepLog());
assertBuildStatusSuccess(downJob.scheduleBuild2(0).get());
waitForBuild(promotionJob, 1);
assertFalse(upBuild.isKeepLog());
}
use of hudson.model.FreeStyleBuild in project promoted-builds-plugin by jenkinsci.
the class KeepBuildForeverActionTest method testDoesNotMarkBuildIfBuildNotPromotion.
public void testDoesNotMarkBuildIfBuildNotPromotion() throws Exception {
FreeStyleProject job = createProject("job");
job.getBuildersList().add(successfulBuilder());
job.getPublishersList().add(new KeepBuildForeverAction());
// fire ItemListeners, this includes ArtifactArchiver,Migrator to make this test compatible with jenkins 1.575+
fireItemListeners();
FreeStyleBuild build = assertBuildStatus(Result.FAILURE, job.scheduleBuild2(0).get());
assertFalse(build.isKeepLog());
}
use of hudson.model.FreeStyleBuild in project promoted-builds-plugin by jenkinsci.
the class KeepBuildForeverActionTest method testCanMarkBuildKeepForever.
public void testCanMarkBuildKeepForever() throws Exception {
FreeStyleProject upJob = createProject("up");
upJob.getBuildersList().add(successfulBuilder());
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 = assertBuildStatusSuccess(upJob.scheduleBuild2(0).get());
assertFalse(upBuild.isKeepLog());
assertBuildStatusSuccess(downJob.scheduleBuild2(0).get());
waitForBuild(promotionJob, 1);
assertTrue(upBuild.isKeepLog());
}
use of hudson.model.FreeStyleBuild in project promoted-builds-plugin by jenkinsci.
the class PromotionsDslContextExtensionTest method testShouldGenerateTheCopyArtifactsJob.
@Test
public void testShouldGenerateTheCopyArtifactsJob() throws Exception {
// Given
String dsl = FileUtils.readFileToString(new File("src/test/resources/copyartifacts-example-dsl.groovy"));
FreeStyleProject seedJob = createFreeStyleProject();
seedJob.getBuildersList().add(new ExecuteDslScripts(new ExecuteDslScripts.ScriptLocation(Boolean.TRUE.toString(), null, dsl), false, RemovedJobAction.DELETE));
// When
QueueTaskFuture<FreeStyleBuild> scheduleBuild2 = seedJob.scheduleBuild2(0);
// Then (unstable b/c we aren't including the CopyArtifacts dependency)
assertBuildStatus(Result.UNSTABLE, scheduleBuild2.get());
TopLevelItem item = jenkins.getItem("copy-artifacts-test");
File config = new File(item.getRootDir(), "promotions/Development/config.xml");
String content = Files.toString(config, Charset.forName("UTF-8"));
assert content.contains("<selector class=\"hudson.plugins.copyartifact.SpecificBuildSelector\">");
}
use of hudson.model.FreeStyleBuild in project promoted-builds-plugin by jenkinsci.
the class GroovyConditionTest method testMapScript.
@Test
public void testMapScript() throws Exception {
FreeStyleProject p = j.createFreeStyleProject();
final JobPropertyImpl property = new JobPropertyImpl(p);
final PromotionProcess promotionProcessEmptyMap = property.addProcess("emptyMap");
promotionProcessEmptyMap.conditions.add(new GroovyCondition(new SecureGroovyScript("[:]", false, null), "", ""));
final PromotionProcess promotionProcessNonEmptyMap = property.addProcess("nonEmptyMap");
promotionProcessNonEmptyMap.conditions.add(new GroovyCondition(new SecureGroovyScript("[foo: 'bar']", false, null), "", ""));
p = j.configRoundtrip(p);
final FreeStyleBuild build = j.buildAndAssertSuccess(p);
Assert.assertNull("Promotion was not expected", promotionProcessEmptyMap.isMet(build));
Assert.assertNotNull("Promotion was expected", promotionProcessNonEmptyMap.isMet(build));
}
Aggregations