use of org.jenkinsci.test.acceptance.junit.Resource in project acceptance-test-harness by jenkinsci.
the class Job method copyResource.
/**
* "Copies" a resource (can be a single file or a directory) to the jobs workspace by utilizing a shell step.
*
* @param resourcePath the resource to copy
*/
public void copyResource(String resourcePath) {
ensureConfigPage();
final Resource res = resource(resourcePath);
// decide whether to utilize copyResource or copyDir
if (res.asFile().isDirectory()) {
copyDir(res);
} else {
copyResource(res);
}
}
use of org.jenkinsci.test.acceptance.junit.Resource in project acceptance-test-harness by jenkinsci.
the class LogParserTest method globalConfig.
@Before
public void globalConfig() {
config = LogParserGlobalConfig.getInstance(jenkins.getConfigPage());
parserRules = new HashMap<>();
// initialize a sample rule for the following test cases
Resource sampleRule = resource("/logparser_plugin/rules/log-parser-rules-sample");
parserRules.put("sampleRule", "" + sampleRule.url.getPath());
addLogParserRules(parserRules);
}
use of org.jenkinsci.test.acceptance.junit.Resource in project acceptance-test-harness by jenkinsci.
the class LogParserTest method configureSampleJob.
private Job configureSampleJob() {
FreeStyleJob job = jenkins.jobs.create(FreeStyleJob.class, "sampleJob");
// configure job
job.configure(() -> {
LogParserPublisher lpp = job.addPublisher(LogParserPublisher.class);
lpp.setRule(LogParserPublisher.RuleType.GLOBAL, parserRules.get("sampleRule"));
// write sample output
Resource sampleRule = resource("/logparser_plugin/console-outputs/sample-log");
catToConsole(job, sampleRule.url.getPath());
});
return job;
}
use of org.jenkinsci.test.acceptance.junit.Resource in project acceptance-test-harness by jenkinsci.
the class GlobalPublishPluginTest method publish_slave_resourses.
@Test
public void publish_slave_resourses() throws IOException, InterruptedException, ExecutionException {
DockerContainer dock = container.get();
Resource cpFile = resource("/ftp_plugin/odes.txt");
Slave s = slaves.get().install(jenkins).get();
s.configure();
s.save();
FreeStyleJob j = jenkins.jobs.create();
configurePublisher("asd", dock);
j.configure();
{
j.copyResource(cpFile);
PublishGlobalPublisher fp = addGlobalPublisher(j);
PublishGlobalPublisher.GlobalPublishSite fps = fp.getDefault();
fps.getDefaultTransfer().sourceFile.set("odes.txt");
}
j.save();
j.startBuild().shouldSucceed();
assertThat(dock.cp("/tmp/odes.txt", "/tmp"), is(true));
assertThat(FileUtils.readFileToString(new File("/tmp/odes.txt")), CoreMatchers.is(cpFile.asText()));
}
use of org.jenkinsci.test.acceptance.junit.Resource in project acceptance-test-harness by jenkinsci.
the class GlobalPublishPluginTest method publish_resources_with_excludes.
@Test
public void publish_resources_with_excludes() {
DockerContainer dock = container.get();
Resource cpDir = resource("/ftp_plugin/");
FreeStyleJob j = jenkins.jobs.create();
configurePublisher("asd", dock);
j.configure();
{
j.copyDir(cpDir);
PublishGlobalPublisher fp = addGlobalPublisher(j);
PublishGlobalPublisher.GlobalPublishSite fps = fp.getDefault();
fps.getDefaultTransfer().sourceFile.set("prefix_/");
fps.getDefaultTransfer().excludes.set("**/*.exclude");
}
j.save();
j.startBuild().shouldSucceed();
assertThat(dock.cp("/tmp/prefix_/", "/tmp"), is(true));
assertThat(!dock.cp("/tmp/prefix_/.exclude", "/tmp"), is(true));
}
Aggregations