/** * Convenience method to call {@link FilePath#copyTo(FilePath)}. * * @since 1.311 */ public void copyFrom(FilePath src) throws IOException, InterruptedException { src.copyTo(this); }
/** * 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 write(File to) throws Exception { new FilePath(file).copyTo(new FilePath(to)); }
@Override public Environment setUp(AbstractBuild build, Launcher launcher, BuildListener listener) throws IOException, InterruptedException { if (!StringUtils.isEmpty(location) && !StringUtils.isEmpty(file.getName())) { listener.getLogger().println("Copying file to "+location); FilePath ws = build.getWorkspace(); if (ws == null) { throw new IllegalStateException("The workspace should be created when setUp method is called"); } if (!ALLOW_FOLDER_TRAVERSAL_OUTSIDE_WORKSPACE && !ws.isDescendant(location)) { listener.error("Rejecting file path escaping base directory with relative path: " + location); // force the build to fail return null; } FilePath locationFilePath = ws.child(location); locationFilePath.getParent().mkdirs(); locationFilePath.copyFrom(file); locationFilePath.copyTo(new FilePath(getLocationUnderBuild(build))); } return new Environment() {}; } };
@WebMethod(name="heapdump.hprof") public void doHeapDump(StaplerRequest req, StaplerResponse rsp) throws IOException, InterruptedException { owner.checkPermission(Jenkins.RUN_SCRIPTS); rsp.setContentType("application/octet-stream"); FilePath dump = obtain(); try { dump.copyTo(rsp.getCompressedOutputStream(req)); } finally { dump.delete(); } }
@SuppressWarnings("deprecation") @Override public ParameterValue createValue(CLICommand command, String value) throws IOException, InterruptedException { // capture the file to the server File local = File.createTempFile("jenkins","parameter"); String name; if (value.isEmpty()) { FileUtils.copyInputStreamToFile(command.stdin, local); name = "stdin"; } else { FilePath src = new FilePath(command.checkChannel(), value); src.copyTo(new FilePath(local)); name = src.getName(); } FileParameterValue p = new FileParameterValue(getName(), local, name); p.setDescription(getDescription()); p.setLocation(getName()); return p; } }
/** * Copies this file to the specified target, with file permissions and other meta attributes intact. * @since 1.311 */ public void copyToWithPermission(FilePath target) throws IOException, InterruptedException { // Use NIO copy with StandardCopyOption.COPY_ATTRIBUTES when copying on the same machine. if (this.channel == target.channel) { act(new CopyToWithPermission(target)); return; } copyTo(target); // copy file permission target.chmod(mode()); target.setLastModifiedIfPossible(lastModified()); } private class CopyToWithPermission extends SecureFileCallable<Void> {
stdout.println(Messages.InstallPluginCommand_InstallingPluginFromLocalFile(f)); String n = name != null ? name : f.getBaseName(); f.copyTo(getTargetFilePath(n)); if (dynamicLoad) pm.dynamicLoad(getTargetFile(n));
/** * Conveniene method to call {@link FilePath#copyTo(FilePath)}. * * @since 1.311 */ public void copyFrom(FilePath src) throws IOException, InterruptedException { src.copyTo(this); }
/** * Conveniene method to call {@link FilePath#copyTo(FilePath)}. * * @since 1.311 */ public void copyFrom(FilePath src) throws IOException, InterruptedException { src.copyTo(this); }
/** * Convenience method to call {@link FilePath#copyTo(FilePath)}. * * @since 1.311 */ public void copyFrom(FilePath src) throws IOException, InterruptedException { src.copyTo(this); }
/** * Conveniene method to call {@link FilePath#copyTo(FilePath)}. * * @since 1.311 */ public void copyFrom(FilePath src) throws IOException, InterruptedException { src.copyTo(this); }
/** * 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); } }
/** * Copies this file to the specified target, with file permissions intact. * @since 1.311 */ public void copyToWithPermission(FilePath target) throws IOException, InterruptedException { copyTo(target); // copy file permission target.chmod(mode()); }
/** * Copies this file to the specified target, with file permissions intact. * * @since 1.311 */ public void copyToWithPermission(FilePath target) throws IOException, InterruptedException { copyTo(target); // copy file permission target.chmod(mode()); }
@Override public Environment setUp(AbstractBuild build, Launcher launcher, BuildListener listener) throws IOException, InterruptedException { if (!StringUtils.isEmpty(location) && !StringUtils.isEmpty(file.getName())) { listener.getLogger().println("Copying file to "+location); FilePath locationFilePath = build.getWorkspace().child(location); locationFilePath.getParent().mkdirs(); locationFilePath.copyFrom(file); locationFilePath.copyTo(new FilePath(getLocationUnderBuild(build))); } return new Environment() {}; } };
private File copyBenchmarkOutputToMaster( AbstractBuild<?, ?> build, FilePath output, String projectFolderName ) throws IOException, InterruptedException { File localReport = getPerformanceReport( build, projectFolderName, output.getName() ); output.copyTo( new FilePath( localReport ) ); return localReport; }
/** * Copies this file to the specified target, with file permissions and other meta attributes intact. * @since 1.311 */ public void copyToWithPermission(FilePath target) throws IOException, InterruptedException { copyTo(target); // copy file permission target.chmod(mode()); target.setLastModifiedIfPossible(lastModified()); }
@WebMethod(name="heapdump.hprof") public void doHeapDump(StaplerRequest req, StaplerResponse rsp) throws IOException, InterruptedException { owner.checkPermission(Hudson.ADMINISTER); rsp.setContentType("application/octet-stream"); FilePath dump = obtain(); try { dump.copyTo(rsp.getCompressedOutputStream(req)); } finally { dump.delete(); } }
@Override public ParameterValue createValue(CLICommand command, String value) throws IOException, InterruptedException { // capture the file to the server FilePath src = new FilePath(command.channel,value); File local = File.createTempFile("hudson","parameter"); src.copyTo(new FilePath(local)); FileParameterValue p = new FileParameterValue(getName(), local, src.getName()); p.setDescription(getDescription()); p.setLocation(getName()); return p; } }