/** * Replaces the content of this file by the data from the given {@link InputStream}. * * @since 1.293 */ public void copyFrom(InputStream in) throws IOException, InterruptedException { try (OutputStream os = write()) { org.apache.commons.io.IOUtils.copy(in, os); } }
/** * Copies this file to the specified target. */ public void copyTo(FilePath target) throws IOException, InterruptedException { try { try (OutputStream out = target.write()) { copyTo(out); } } catch (IOException e) { throw new IOException("Failed to copy "+this+" to "+target,e); } }
public void zip(FilePath dst) throws IOException, InterruptedException { try (OutputStream os = dst.write()) { zip(os); } }
@VisibleForTesting void save() throws IOException, InterruptedException { try (OutputStream os = store.write()) { props.store(os, "Credential store"); } // try to protect this file from other users, if we can. store.chmod(0600); }
/** * Place the data from {@link FileItem} into the file location specified by this {@link FilePath} object. */ public void copyFrom(FileItem file) throws IOException, InterruptedException { if(channel==null) { try { file.write(writing(new File(remote))); } catch (IOException e) { throw e; } catch (Exception e) { throw new IOException(e); } } else { try (InputStream i = file.getInputStream(); OutputStream o = write()) { org.apache.commons.io.IOUtils.copy(i,o); } } }
public FilePath performInstallation(ToolInstallation tool, Node node, TaskListener log) throws IOException, InterruptedException { FilePath expected = preferredLocation(tool, node); Installable inst = getInstallable(); if(inst==null) { log.getLogger().println("Invalid tool ID "+id); return expected; } if (inst instanceof NodeSpecific) { inst = (Installable) ((NodeSpecific) inst).forNode(node, log); } if(isUpToDate(expected,inst)) return expected; if(expected.installIfNecessaryFrom(new URL(inst.url), log, "Unpacking " + inst.url + " to " + expected + " on " + node.getDisplayName())) { expected.child(".timestamp").delete(); // we don't use the timestamp FilePath base = findPullUpDirectory(expected); if(base!=null && base!=expected) base.moveAllChildrenTo(expected); // leave a record for the next up-to-date check expected.child(".installedFrom").write(inst.url,"UTF-8"); expected.act(new ZipExtractionInstaller.ChmodRecAPlusX()); } return expected; }
iapf.write(randomUUID + System.lineSeparator(), "UTF-8");
/** * Replaces the content of this file by the data from the given {@link InputStream}. * * @since 1.293 */ public void copyFrom(InputStream in) throws IOException, InterruptedException { try (OutputStream os = write()) { org.apache.commons.io.IOUtils.copy(in, os); } }
@VisibleForTesting void save() throws IOException, InterruptedException { try (OutputStream os = store.write()) { props.store(os, "Credential store"); } // try to protect this file from other users, if we can. store.chmod(0600); } }
public void zip(FilePath dst) throws IOException, InterruptedException { try (OutputStream os = dst.write()) { zip(os); } }
/** * Copies this file to the specified target. */ public void copyTo(FilePath target) throws IOException, InterruptedException { try { try (OutputStream out = target.write()) { copyTo(out); } } catch (IOException e) { throw new IOException("Failed to copy "+this+" to "+target,e); } }
@Override public void checkout(Run<?,?> build, Launcher launcher, FilePath workspace, TaskListener listener, File changelogFile, SCMRevisionState baseline) throws IOException, InterruptedException { listener.getLogger().println("Staging "+path); OutputStream os = workspace.child(path).write(); IOUtils.write(contents, os); os.close(); }
@Override public boolean checkout(AbstractBuild build, Launcher launcher, FilePath workspace, BuildListener listener, File changeLogFile) throws IOException, InterruptedException { listener.getLogger().println("Staging "+path); OutputStream os = workspace.child(path).write(); IOUtils.write(contents, os); os.close(); return true; }
@Override public boolean checkout(AbstractBuild build, Launcher launcher, FilePath workspace, BuildListener listener, File changeLogFile) throws IOException, InterruptedException { listener.getLogger().println("Staging " + path); OutputStream os = workspace.child(path).write(); IOUtils.write(contents, os); os.close(); return true; }
@Override public boolean perform(AbstractBuild<?, ?> build, Launcher launcher, BuildListener listener) throws InterruptedException, IOException { listener.getLogger().println("Creating a file " + fileName); FilePath workspace = build.getWorkspace(); if (workspace == null) { throw new AbortException("Cannot get the workspace of the build"); } workspace.child(fileName).write(fileContent, "UTF-8"); return true; }
private FilePath fetchConfig(FilePath workspace) throws Exception { SSHClient sshClient = new SSHClient(host, port, credentials); try (SSHClient ignore = sshClient.connect()) { FilePath configFile = workspace.createTempFile(Constants.KUBECONFIG_PREFIX, ""); try (OutputStream out = configFile.write()) { sshClient.copyFrom(Constants.KUBECONFIG_FILE, out); } return configFile; } } }
@Override public boolean perform(AbstractBuild<?, ?> build, Launcher launcher, BuildListener listener) throws InterruptedException, IOException { build.getWorkspace().child(fileName).write(content, "UTF-8"); return true; } };
@Override public boolean perform(AbstractBuild<?, ?> build, Launcher launcher, BuildListener listener) throws InterruptedException, IOException { build.getWorkspace().child(fileName).write(content, "UTF-8"); return true; } };
@Override public MarathonBuilder toFile(final String filename) throws InterruptedException, IOException, MarathonFileInvalidException { final String realFilename = filename != null ? filename : MarathonBuilderUtils.MARATHON_RENDERED_JSON; final FilePath renderedFilepath = workspace.child(Util.replaceMacro(realFilename, envVars)); if (renderedFilepath.exists() && renderedFilepath.isDirectory()) throw new MarathonFileInvalidException("File '" + realFilename + "' is a directory; not overwriting."); renderedFilepath.write(json.toString(), null); return this; }
@Override public void evaluate() throws Throwable { WorkflowJob p = jenkins.getItemByFullName("p", WorkflowJob.class); WorkflowRun b = p.getBuildByNumber(2); SemaphoreStep.success("wait/1", null); story.j.assertLogContains("a ran on value from b", story.j.assertBuildStatusSuccess(story.j.waitForCompletion(b))); // Better case: jenkins.getWorkspaceFor(p).child("b.groovy").write("def m(a, arg) {a(\"${arg} from b\")}; this", null); p.setDefinition(new CpsFlowDefinition("def a; def b; node {a = load 'a.groovy'; b = load 'b.groovy'}; b.m(a, 'value')", true)); story.j.assertLogContains("a ran on value from b", story.j.assertBuildStatusSuccess(p.scheduleBuild2(0))); } });