use of org.jenkinsci.test.acceptance.controller.LocalController in project acceptance-test-harness by jenkinsci.
the class Job method copyFile.
/**
* "Copy" any file from the System into the Workspace using a zipFIle.
*
* Differentiates when the file is being run on Windows or Unix based machines.
*
* @param file
*/
public void copyFile(File file) {
File tmp = null;
try {
tmp = File.createTempFile("jenkins-acceptance-tests", "dir");
ZipUtil.pack(file, tmp);
byte[] archive = IOUtils.toByteArray(new FileInputStream(tmp));
if (SystemUtils.IS_OS_WINDOWS) {
if (!(controller instanceof LocalController)) {
// TODO: Make it work for RemoteJenkinsController like in Unix (below)
throw new AssumptionViolatedException("Copying files in Windows is only supported if a LocalController is in use. Test will be skipped.");
}
addBatchStep(xCopy(file.getAbsolutePath(), "%cd%"));
} else {
addShellStep(String.format("base64 --decode << ENDOFFILE > archive.zip && unzip -o archive.zip \n%s\nENDOFFILE", new String(Base64.encodeBase64Chunked(archive))));
}
} catch (IOException e) {
throw new AssertionError(e);
} finally {
if (tmp != null) {
tmp.delete();
}
}
}
use of org.jenkinsci.test.acceptance.controller.LocalController in project acceptance-test-harness by jenkinsci.
the class WizardLogin method getPassword.
/**
* Gets the generated password from the file on disk
*
* @return the read password
* @throws IOException if there is an IO error
*/
public String getPassword(JenkinsController controller) throws IOException {
Assume.assumeThat("Testing the setup wizard is only supported if a LocalController is in use. Test will be skipped.", controller, instanceOf(LocalController.class));
File passwordFile = new File(((LocalController) controller).getJenkinsHome(), "secrets/initialAdminPassword");
String pass = FileUtils.readFileToString(passwordFile).trim();
return pass;
}
use of org.jenkinsci.test.acceptance.controller.LocalController in project acceptance-test-harness by jenkinsci.
the class WorkflowPluginTest method grapeLibrary.
@WithPlugins({ "workflow-cps-global-lib@2.3", "workflow-basic-steps@2.1", "workflow-job@2.5" })
@Issue("JENKINS-26192")
@Test
public void grapeLibrary() throws Exception {
assumeThat("TODO otherwise we would need to set up SSH access to push via Git, which seems an awful hassle", controller, instanceOf(LocalController.class));
File workflowLibs = /* WorkflowLibRepository.workspace() */
new File(((LocalController) controller).getJenkinsHome(), "workflow-libs");
// Cf. GrapeTest.useBinary using JenkinsRule:
FileUtils.write(new File(workflowLibs, "src/pkg/Lists.groovy"), "package pkg\n" + "@Grab('commons-primitives:commons-primitives:1.0')\n" + "import org.apache.commons.collections.primitives.ArrayIntList\n" + "static def arrayInt() {new ArrayIntList()}");
WorkflowJob job = jenkins.jobs.create(WorkflowJob.class);
job.script.set("echo(/got ${pkg.Lists.arrayInt()}/)");
job.sandbox.check();
job.save();
assertThat(job.startBuild().shouldSucceed().getConsole(), containsString("got []"));
}
Aggregations