Search in sources :

Example 1 with TestBuildWrapper

use of org.jvnet.hudson.test.JenkinsRule.TestBuildWrapper in project promoted-builds-plugin by jenkinsci.

the class PromotionBuildWrapperTest method testApplyBuildWrapper.

@Test
public void testApplyBuildWrapper() throws Exception {
    FreeStyleProject project = j.createFreeStyleProject();
    JobPropertyImpl jobProperty = new JobPropertyImpl(project);
    project.addProperty(jobProperty);
    PromotionProcess promotion = jobProperty.addProcess("test");
    TestBuildWrapper buildWrapper = new TestBuildWrapper();
    promotion.getBuildWrappersList().add(buildWrapper);
    promotion.getBuildSteps().add(Functions.isWindows() ? new BatchFile("echo Hello, world") : new Shell("echo Hello, world"));
    // trigger build
    FreeStyleBuild build = j.assertBuildStatusSuccess(project.scheduleBuild2(0).get());
    // trigger promotion
    promotion.promote(build, new Cause.UserIdCause(), new ManualPromotionBadge());
    Thread.sleep(1000);
    assertEquals(1, promotion.getBuilds().size());
    Promotion promotionBuild = promotion.getBuilds().get(0);
    assertSame(promotionBuild.getTargetBuildOrFail(), build);
    assertEquals(Result.SUCCESS, buildWrapper.buildResultInTearDown);
}
Also used : TestBuildWrapper(org.jvnet.hudson.test.JenkinsRule.TestBuildWrapper) BatchFile(hudson.tasks.BatchFile) Shell(hudson.tasks.Shell) Cause(hudson.model.Cause) FreeStyleBuild(hudson.model.FreeStyleBuild) FreeStyleProject(hudson.model.FreeStyleProject) Test(org.junit.Test)

Aggregations

Cause (hudson.model.Cause)1 FreeStyleBuild (hudson.model.FreeStyleBuild)1 FreeStyleProject (hudson.model.FreeStyleProject)1 BatchFile (hudson.tasks.BatchFile)1 Shell (hudson.tasks.Shell)1 Test (org.junit.Test)1 TestBuildWrapper (org.jvnet.hudson.test.JenkinsRule.TestBuildWrapper)1