use of org.jenkinsci.plugins.configfiles.buildwrapper.ConfigFileBuildWrapper in project promoted-builds-plugin by jenkinsci.
the class ConfigurationRoundtripTest method testRoundtrip.
/**
* Configuration roundtrip test to detect data loss.
*/
@Test
public void testRoundtrip() throws Exception {
FreeStyleProject down = j.createFreeStyleProject();
FreeStyleProject p = j.createFreeStyleProject();
JobPropertyImpl pp = new JobPropertyImpl(p);
p.addProperty(pp);
PromotionProcess proc = pp.addProcess("test");
assertEquals(1, pp.getItems().size());
proc.conditions.add(new DownstreamPassCondition(down.getName()));
proc.getBuildSteps().add(new JavadocArchiver("somedir", true));
proc.getBuildWrappersList().add(new ConfigFileBuildWrapper(new ArrayList<ManagedFile>()));
proc.icon = "star-blue";
// round trip
JenkinsRule.WebClient wc = j.createWebClient();
submit(wc.getPage(p, "configure").getFormByName("config"));
// assert that the configuration is still intact
pp = p.getProperty(JobPropertyImpl.class);
assertEquals(1, pp.getItems().size());
proc = pp.getItem("test");
assertEquals(1, proc.conditions.toList().size());
DownstreamPassCondition dcp = proc.conditions.get(DownstreamPassCondition.class);
assertEquals(dcp.getJobs(), down.getName());
assertEquals(1, proc.getBuildSteps().size());
JavadocArchiver ja = (JavadocArchiver) proc.getBuildSteps().get(0);
assertEquals("somedir", ja.getJavadocDir());
assertTrue(ja.isKeepAll());
ConfigFileBuildWrapper buildWrapper = (ConfigFileBuildWrapper) proc.getBuildWrappersList().get(0);
assertNotNull(buildWrapper);
assertEquals("star-blue", proc.icon);
}
use of org.jenkinsci.plugins.configfiles.buildwrapper.ConfigFileBuildWrapper in project workflow-cps-plugin by jenkinsci.
the class StepNodeTest method metastepConsoleShellClass.
@Test
public void metastepConsoleShellClass() throws Exception {
WorkflowJob p = r.createProject(WorkflowJob.class);
p.setDefinition(new CpsFlowDefinition("node {\n" + " wrap([$class: 'ConfigFileBuildWrapper', managedFiles: []]) {\n" + " writeFile text: '''<testsuite name='a'><testcase name='c'><error>failed</error></testcase></testsuite>''', file: 'x.xml'\n" + " step([$class: 'ArtifactArchiver', artifacts: 'x.xml'])\n" + " }\n" + "}", true));
WorkflowRun b = r.buildAndAssertSuccess(p);
List<FlowNode> coreStepNodes = new DepthFirstScanner().filteredNodes(b.getExecution(), new NodeStepTypePredicate("step"));
assertThat(coreStepNodes, hasSize(1));
assertEquals("archiveArtifacts", coreStepNodes.get(0).getDisplayFunctionName());
assertEquals(r.jenkins.getDescriptor(ArtifactArchiver.class).getDisplayName(), coreStepNodes.get(0).getDisplayName());
List<FlowNode> coreWrapperStepNodes = new DepthFirstScanner().filteredNodes(b.getExecution(), Predicates.and(new NodeStepTypePredicate("wrap"), new Predicate<FlowNode>() {
@Override
public boolean apply(FlowNode n) {
return n instanceof StepStartNode && !((StepStartNode) n).isBody();
}
}));
assertThat(coreWrapperStepNodes, hasSize(1));
assertEquals("configFileProvider", coreWrapperStepNodes.get(0).getDisplayFunctionName());
assertEquals(r.jenkins.getDescriptor(ConfigFileBuildWrapper.class).getDisplayName() + " : Start", coreWrapperStepNodes.get(0).getDisplayName());
r.assertLogContains("[Pipeline] archiveArtifacts", b);
r.assertLogContains("[Pipeline] configFileProvider", b);
r.assertLogContains("[Pipeline] // configFileProvider", b);
}
Aggregations