Search in sources :

Example 21 with FreeStyleBuild

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());
}
Also used : FreeStyleBuild(hudson.model.FreeStyleBuild) FreeStyleProject(hudson.model.FreeStyleProject)

Example 22 with FreeStyleBuild

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());
}
Also used : FreeStyleBuild(hudson.model.FreeStyleBuild) FreeStyleProject(hudson.model.FreeStyleProject)

Example 23 with FreeStyleBuild

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());
}
Also used : FreeStyleBuild(hudson.model.FreeStyleBuild) FreeStyleProject(hudson.model.FreeStyleProject)

Example 24 with FreeStyleBuild

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\">");
}
Also used : ExecuteDslScripts(javaposse.jobdsl.plugin.ExecuteDslScripts) TopLevelItem(hudson.model.TopLevelItem) FreeStyleBuild(hudson.model.FreeStyleBuild) FreeStyleProject(hudson.model.FreeStyleProject) File(java.io.File) Test(org.junit.Test)

Example 25 with FreeStyleBuild

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));
}
Also used : PromotionProcess(hudson.plugins.promoted_builds.PromotionProcess) FreeStyleBuild(hudson.model.FreeStyleBuild) FreeStyleProject(hudson.model.FreeStyleProject) JobPropertyImpl(hudson.plugins.promoted_builds.JobPropertyImpl) SecureGroovyScript(org.jenkinsci.plugins.scriptsecurity.sandbox.groovy.SecureGroovyScript) Test(org.junit.Test)

Aggregations

FreeStyleBuild (hudson.model.FreeStyleBuild)42 FreeStyleProject (hudson.model.FreeStyleProject)42 Test (org.junit.Test)25 JobPropertyImpl (hudson.plugins.promoted_builds.JobPropertyImpl)14 PromotionProcess (hudson.plugins.promoted_builds.PromotionProcess)13 Shell (hudson.tasks.Shell)13 Map (java.util.Map)12 ImmutableMap (com.google.common.collect.ImmutableMap)11 PromotedBuildAction (hudson.plugins.promoted_builds.PromotedBuildAction)8 Promotion (hudson.plugins.promoted_builds.Promotion)7 StringParameterDefinition (hudson.model.StringParameterDefinition)6 ManualCondition (hudson.plugins.promoted_builds.conditions.ManualCondition)6 ManualApproval (hudson.plugins.promoted_builds.conditions.ManualCondition.ManualApproval)6 Descriptor (hudson.model.Descriptor)5 ParameterValue (hudson.model.ParameterValue)5 StringParameterValue (hudson.model.StringParameterValue)4 MockFolder (org.jvnet.hudson.test.MockFolder)4 HtmlPage (com.gargoylesoftware.htmlunit.html.HtmlPage)3 Project (hudson.model.Project)3 DescriptorImpl (hudson.plugins.promoted_builds.JobPropertyImpl.DescriptorImpl)3