Search in sources :

Example 1 with ConfigFileBuildStep

use of org.jenkinsci.plugins.configfiles.builder.ConfigFileBuildStep in project promoted-builds-plugin by jenkinsci.

the class PromotionConfigFilesTest method testPromotionConfigFilesAreRetrievedFromParentJobContext.

@Test
public void testPromotionConfigFilesAreRetrievedFromParentJobContext() throws Exception {
    GlobalConfigFiles store = r.getInstance().getExtensionList(GlobalConfigFiles.class).get(GlobalConfigFiles.class);
    Assert.assertTrue(store.getConfigs().isEmpty());
    CustomConfig config = new CustomConfig(CONFIG_ID, "name", "comment", "content");
    store.save(config);
    FreeStyleProject p = r.createFreeStyleProject();
    // promote if the downstream passes
    JobPropertyImpl promotion = new JobPropertyImpl(p);
    p.addProperty(promotion);
    PromotionProcess promo1 = promotion.addProcess("promo1");
    promo1.conditions.add(new SelfPromotionCondition(false));
    List<ManagedFile> managedFiles = new ArrayList<>();
    managedFiles.add(new ManagedFile(CONFIG_ID));
    promo1.getBuildSteps().add(new ConfigFileBuildStep(managedFiles));
    r.assertBuildStatusSuccess(p.scheduleBuild2(0));
    // internally, the promotion is still an asynchronous process. It just happens
    // right away after the build is complete.
    Thread.sleep(1000);
    Promotion pb = promo1.getBuilds().iterator().next();
    assertEquals(Result.SUCCESS, pb.getResult());
}
Also used : CustomConfig(org.jenkinsci.plugins.configfiles.custom.CustomConfig) GlobalConfigFiles(org.jenkinsci.plugins.configfiles.GlobalConfigFiles) ArrayList(java.util.ArrayList) ConfigFileBuildStep(org.jenkinsci.plugins.configfiles.builder.ConfigFileBuildStep) SelfPromotionCondition(hudson.plugins.promoted_builds.conditions.SelfPromotionCondition) FreeStyleProject(hudson.model.FreeStyleProject) ManagedFile(org.jenkinsci.plugins.configfiles.buildwrapper.ManagedFile) Test(org.junit.Test)

Aggregations

FreeStyleProject (hudson.model.FreeStyleProject)1 SelfPromotionCondition (hudson.plugins.promoted_builds.conditions.SelfPromotionCondition)1 ArrayList (java.util.ArrayList)1 GlobalConfigFiles (org.jenkinsci.plugins.configfiles.GlobalConfigFiles)1 ConfigFileBuildStep (org.jenkinsci.plugins.configfiles.builder.ConfigFileBuildStep)1 ManagedFile (org.jenkinsci.plugins.configfiles.buildwrapper.ManagedFile)1 CustomConfig (org.jenkinsci.plugins.configfiles.custom.CustomConfig)1 Test (org.junit.Test)1