/** * Short for {@code getParent().child(rel)}. Useful for getting other files in the same directory. */ public FilePath sibling(String rel) { return getParent().child(rel); }
@Override public VirtualFile getParent() { return f.getParent().toVirtualFile(); } @Override public boolean isDirectory() throws IOException {
/** * To be kept in sync with {@link FileVF#computeRelativePathToRoot()} */ private String computeRelativePathToRoot(){ if (this.root.equals(this.f)) { return ""; } LinkedList<String> relativePath = new LinkedList<>(); FilePath current = this.f; while (current != null && !current.equals(this.root)) { relativePath.addFirst(current.getName()); current = current.getParent(); } return String.join(File.separator, relativePath) + File.separator; } }
@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() {}; } };
/** * Short for {@code getParent().child(rel)}. Useful for getting other files in the same directory. */ public FilePath sibling(String rel) { return getParent().child(rel); }
/** * Short for {@code getParent().child(rel)}. Useful for getting other files in the same directory. */ public FilePath sibling(String rel) { return getParent().child(rel); }
@Override public VirtualFile getParent() { return f.getParent().toVirtualFile(); } @Override public boolean isDirectory() throws IOException {
/** * Short for {@code getParent().child(rel)}. Useful for getting other files * in the same directory. */ public FilePath sibling(String rel) { return getParent().child(rel); }
/** * Short for {@code getParent().child(rel)}. Useful for getting other files in the same directory. */ public FilePath sibling(String rel) { return getParent().child(rel); }
private boolean isSubDirectory(FilePath parent, FilePath child) { FilePath parentFolder = child; while (parentFolder!=null) { if (parent.equals(parentFolder)) { return true; } parentFolder = parentFolder.getParent(); } return false; }
/** * Short for {@code getParent().child(rel)}. Useful for getting other files in the same directory. */ public FilePath sibling(String rel) { return getParent().child(rel); }
public DirectoryBrowserSupport doDynamic(StaplerRequest req, StaplerResponse rsp) throws IOException, ServletException, InterruptedException { // backward compatibility // since 0.3 FilePath path = buildReportPath; if (!buildReportPath.exists()) { path = buildReportPath.getParent(); } return new DirectoryBrowserSupport(this, path, "Clover Html Report", CloverProjectAction.ICON, false); }
@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 boolean copyHtmlReport(FilePath coverageReportDir, FilePath buildTarget, BuildListener listener) throws IOException, InterruptedException { // Copy the HTML coverage report final FilePath htmlIndexHtmlPath = coverageReportDir.child("index.html"); if (htmlIndexHtmlPath.exists()) { final FilePath htmlDirPath = htmlIndexHtmlPath.getParent(); listener.getLogger().println("Publishing Clover HTML report..."); htmlDirPath.copyRecursiveTo("**/*", buildTarget); return true; } return false; }
@Override public Environment setUp(AbstractBuild build, Launcher launcher, BuildListener listener) throws IOException, InterruptedException { if (!StringUtils.isEmpty(file.getName())) { listener.getLogger().println("Copying file to "+location); FilePath locationFilePath = build.getWorkspace().child(location); locationFilePath.getParent().mkdirs(); locationFilePath.copyFrom(file); file = null; locationFilePath.copyTo(new FilePath(getLocationUnderBuild(build))); } return new Environment() {}; } };
@Override public Environment setUp(AbstractBuild build, Launcher launcher, BuildListener listener) throws IOException, InterruptedException { if (!StringUtils.isEmpty(file.getName())) { listener.getLogger().println("Copying file to " + location); FilePath locationFilePath = build.getWorkspace().child(location); locationFilePath.getParent().mkdirs(); locationFilePath.copyFrom(file); file = null; locationFilePath.copyTo(new FilePath(getLocationUnderBuild(build))); } return new Environment() { }; } };
@Override public Environment setUp(AbstractBuild build, Launcher launcher, BuildListener listener) throws IOException, InterruptedException { if (!StringUtils.isEmpty(file.getName())) { listener.getLogger().println("Copying file to "+location); FilePath locationFilePath = build.getWorkspace().child(location); locationFilePath.getParent().mkdirs(); locationFilePath.copyFrom(file); file = null; locationFilePath.copyTo(new FilePath(getLocationUnderBuild(build))); } return new Environment() {}; } };
@Override public Environment setUp(AbstractBuild build, Launcher launcher, BuildListener listener) throws IOException, InterruptedException { if (!StringUtils.isEmpty(file.getName())) { listener.getLogger().println("Copying file to "+location); FilePath locationFilePath = build.getWorkspace().child(location); locationFilePath.getParent().mkdirs(); locationFilePath.copyFrom(file); file = null; locationFilePath.copyTo(new FilePath(getLocationUnderBuild(build))); } return new Environment() {}; } };
@Override protected FileWrapper run() throws Exception { FilePath file = ws.child(step.getFile()); long timestamp = step.getTimestamp() != null ? step.getTimestamp() : System.currentTimeMillis(); file.getParent().mkdirs(); file.touch(timestamp); return new FileWrapper(file); } }
@Override protected FileWrapper run() throws Exception { FilePath ws = getContext().get(FilePath.class); assert ws != null; FilePath file = ws.child(step.getFile()); long timestamp = step.getTimestamp() != null ? step.getTimestamp() : System.currentTimeMillis(); file.getParent().mkdirs(); file.touch(timestamp); return new FileWrapper(file); } }