use of org.jenkinsci.test.acceptance.po.FreeStyleJob in project acceptance-test-harness by jenkinsci.
the class JobDslPluginTest method should_ignore_existing_jobs.
/**
* Verifies whether previously generated jobs will be ignored or updated.
* By default, all previous generated jobs will be updated.
* If existing jobs should be ignored, the plugin do not modify previous
* generated jobs.
*/
@Test
public void should_ignore_existing_jobs() {
FreeStyleJob seedJob = createSeedJob();
JobDslBuildStep jobDsl = seedJob.addBuildStep(JobDslBuildStep.class);
jobDsl.setScript("job('Existing_Job') {\n" + " description('Existing description');\n" + "}");
seedJob.save();
seedJob.scheduleBuild().shouldSucceed();
FreeStyleJob existingJob = getJob("Existing_Job");
seedJob.configure(() -> {
jobDsl.setScript("job('Existing_Job') {\n" + " description('This is a description');\n" + "}");
jobDsl.setIgnoreExisting(true);
});
Build build = seedJob.scheduleBuild().shouldSucceed();
Pattern expected = Pattern.compile("Existing items:(\\s*)GeneratedJob[{]name='Existing_Job'}");
assertThat(build.getConsole(), containsRegexp(expected));
checkDescription(existingJob, "Existing description");
seedJob.configure(() -> jobDsl.setIgnoreExisting(false));
Build build2 = seedJob.scheduleBuild().shouldSucceed();
assertThat(build2.getConsole(), containsRegexp(expected));
checkDescription(existingJob, "This is a description");
}
use of org.jenkinsci.test.acceptance.po.FreeStyleJob in project acceptance-test-harness by jenkinsci.
the class JobDslPluginTest method should_show_job_dsl_api_reference.
/**
* Verifies that the sidebar link 'Job DSL API Reference' on the project page of a job
* is only shown if the job contains a Job DSL build step.
* Further it checks that the API page could be shown if the link was clicked.
*/
@Test
public void should_show_job_dsl_api_reference() {
String hrefLocator = "/plugin/job-dsl/api-viewer/index.html";
FreeStyleJob seedJob = createSeedJob();
seedJob.open();
assertThat(driver, not(hasElement(by.href(hrefLocator))));
seedJob.configure(() -> seedJob.addBuildStep(JobDslBuildStep.class));
find(by.href(hrefLocator)).click();
assertThat(driver, hasElement(by.link("Jenkins Job DSL Plugin")));
seedJob.configure(seedJob::removeFirstBuildStep);
assertThat(driver, not(hasElement(by.href(hrefLocator))));
}
use of org.jenkinsci.test.acceptance.po.FreeStyleJob in project acceptance-test-harness by jenkinsci.
the class JobDslPluginTest method createJobThatFails.
/**
* This method creates a job which uses a job DSL script that fails its build.
* @return job that failed
*/
private Job createJobThatFails() {
String jobDslScriptFailed = "fail";
FreeStyleJob job = createJobAndSetJobDslScript(jobDslScriptFailed, false);
job.scheduleBuild().shouldFail();
return job;
}
use of org.jenkinsci.test.acceptance.po.FreeStyleJob in project acceptance-test-harness by jenkinsci.
the class JobDslPluginTest method should_ignore_removed_config_files.
/**
* Verifies whether a previously generated config file will be ignored if it
* is not referenced anymore.
*/
@Test
@WithPlugins("config-file-provider")
public void should_ignore_removed_config_files() {
FreeStyleJob seedJob = executeRemovedConfigFilesAction(JobDslRemovedConfigFilesAction.IGNORE);
Build build = seedJob.scheduleBuild().shouldSucceed();
Pattern expected = Pattern.compile("Unreferenced config files:(\\s*)GeneratedConfigFile[{]name='Old_Config_File', id='123456789'}");
assertThat(build.getConsole(), containsRegexp(expected));
ConfigFileProvider configFileProvider = new ConfigFileProvider(jenkins);
configFileProvider.open();
assertThat(driver, hasElement(by.xpath("//a[@href='editConfig?id=123456789']")));
}
use of org.jenkinsci.test.acceptance.po.FreeStyleJob in project acceptance-test-harness by jenkinsci.
the class JobDslPluginTest method should_lookup_at_seed_job.
/**
* Verifies that relative job names are interpreted relative to the folder in which
* the seed job is located.
*/
@Test
@WithPlugins("cloudbees-folder")
public void should_lookup_at_seed_job() {
Folder folder = runSeedJobInFolder("New_Job", JobDslLookupStrategy.SEED_JOB);
FreeStyleJob newJob = getJob("New_Job");
assertThat(newJob, pageObjectDoesNotExist());
newJob = folder.getJobs().get(FreeStyleJob.class, "New_Job");
assertThat(newJob, pageObjectExists());
}
Aggregations