/** * Constructor using fields * * @param home * The home folder * @throws InterruptedException * @throws IOException */ protected Python(FilePath home) throws IOException, InterruptedException { // Call super super(); // Store home folder with its absolute form setHome(home.absolutize()); }
@Override public FilePath getRootPath() { FilePath rootPath = createPath(remoteFS); if (rootPath != null) { try { // Construct absolute path for slave's remote file system root. rootPath = rootPath.absolutize(); } catch (IOException e) { LOGGER.warning("IO exception while absolutizing slave root path: " +e); } catch (InterruptedException e) { LOGGER.warning("InterruptedException while absolutizing slave root path: " +e); } } // Return root path even if we caught an exception, // let the caller handle the error. return rootPath; }
private FilePath getSourceDirectory(FilePath basePath) throws IOException, InterruptedException { String subdirectory = StringUtils.trimToEmpty(getSubdirectoryFromEnv()); if (!subdirectory.isEmpty() && !subdirectory.startsWith("/")) { subdirectory = "/" + subdirectory; } FilePath sourcePath = basePath.withSuffix(subdirectory).absolutize(); if (!sourcePath.isDirectory() || !isSubDirectory(basePath, sourcePath)) { throw new IllegalArgumentException("Provided path (resolved as '" + sourcePath +"') is not a subdirectory of the workspace (resolved as '" + basePath + "')"); } return sourcePath; }
} else { listener.getLogger().println( "Didn't find comment file in workspace at " + path.absolutize().getRemote() + ", falling back to file operations on master." );
public String getEnForceResults(AbstractBuild<?,?> build) throws IOException, InterruptedException { String contentFile = build.getWorkspace().absolutize().getRemote() + "/build/report/coverage.json"; StringBuilder result = new StringBuilder(); File coverageFile = new File(contentFile);
public String getTargetDir(String targetDir, String relativeDir) throws IOException { try { String downloadFileRelativePath = this.flatDownload && relativeDir.contains("/") ? StringUtils.substringAfterLast(relativeDir, "/") : relativeDir; FilePath targetDirFile = new FilePath(workspace, targetDir).child(downloadFileRelativePath); return targetDirFile.absolutize().getRemote(); } catch (InterruptedException e) { log.warn("Caught interrupted exception: " + e.getLocalizedMessage()); } return null; }
/** * Return the filepaths in the workspace which match the pattern. * * @param build The Jenkins build. * @param pattern An ant-style pattern. * @return an array of FilePaths which match this pattern in the * Jenkins workspace. */ private FilePath[] getFilePaths(AbstractBuild<?, ?> build, String pattern) { FilePath workspace = build.getWorkspace(); String logEntry = "Searching ant pattern '" + pattern + "'"; FilePath[] uploadFilePaths = new FilePath[0]; try { uploadFilePaths = workspace.list(pattern); logEntry += " in " + workspace.absolutize().getRemote(); } catch (IOException ioe) { this.logConsole("Could not list workspace due to IOException: " + ioe.getMessage()); } catch (InterruptedException ie) { this.logConsole("Could not list workspace due to " + "InterruptedException: " + ie.getMessage()); } logEntry += " : found " + uploadFilePaths.length + " entry(ies)"; logConsole(logEntry); return uploadFilePaths; }
try { uploadFilePaths = workspace.list(pattern); logEntry += " in " + workspace.absolutize().getRemote(); } catch (IOException ioe) { this.logConsole("Could not list workspace due to IOException: "
public FilePath performInstallation(ToolInstallation tool, Node node, TaskListener log) throws IOException, InterruptedException { FilePath expectedLocation = preferredLocation(tool, node); PrintStream out = log.getLogger(); try { if(!acceptLicense) { out.println(Messages.JDKInstaller_UnableToInstallUntilLicenseAccepted()); return expectedLocation; } // already installed? FilePath marker = expectedLocation.child(".installedByHudson"); if (marker.exists() && marker.readToString().equals(id)) { return expectedLocation; } expectedLocation.deleteRecursive(); expectedLocation.mkdirs(); Platform p = Platform.of(node); URL url = locate(log, p, CPU.of(node)); out.println("Downloading "+url); FilePath file = expectedLocation.child(p.bundleFileName); file.copyFrom(url); // JDK6u13 on Windows doesn't like path representation like "/tmp/foo", so make it a strict platform native format by doing 'absolutize' install(node.createLauncher(log), p, new FilePathFileSystem(node), log, expectedLocation.absolutize().getRemote(), file.getRemote()); // successfully installed file.delete(); marker.write(id, null); } catch (DetectionFailedException e) { out.println("JDK installation skipped: "+e.getMessage()); } return expectedLocation; }
if (option == SetcsOption.CONFIGSPEC) { configSpecFile = launcher.getWorkspace().createTextTempFile("configspec", ".txt", configSpec); cmd.add(PathUtil.convertPathForOS(configSpecFile.absolutize().getRemote(), launcher.getLauncher().isUnix()));
public void removeUnusedArtifactsFromLocal(Set<String> allResolvesFiles, Set<String> forDeletionFiles) throws IOException { try { for (String resolvedFile : forDeletionFiles) { FilePath resolvedFileParent = workspace.child(resolvedFile).getParent(); if (!resolvedFileParent.exists()) { continue; } List<FilePath> fileSiblings = resolvedFileParent.list(); if (fileSiblings == null || fileSiblings.isEmpty()) { continue; } for (FilePath sibling : fileSiblings) { String siblingPath = sibling.absolutize().getRemote(); if (!isResolvedOrParentOfResolvedFile(allResolvesFiles, siblingPath)) { sibling.deleteRecursive(); log.info("Deleted unresolved file '" + siblingPath + "'"); } } } } catch (InterruptedException e) { log.warn("Caught interrupted exception: " + e.getLocalizedMessage()); } }
public FilePath performInstallation(ToolInstallation tool, Node node, TaskListener log) throws IOException, InterruptedException { FilePath expectedLocation = preferredLocation(tool, node); PrintStream out = log.getLogger(); try { if(!acceptLicense) { out.println(Messages.JDKInstaller_UnableToInstallUntilLicenseAccepted()); return expectedLocation; } // already installed? FilePath marker = expectedLocation.child(".installedByHudson"); if (marker.exists() && marker.readToString().equals(id)) { return expectedLocation; } expectedLocation.deleteRecursive(); expectedLocation.mkdirs(); Platform p = Platform.of(node); URL url = locate(log, p, CPU.of(node)); out.println("Downloading "+url); FilePath file = expectedLocation.child(p.bundleFileName); file.copyFrom(url); // JDK6u13 on Windows doesn't like path representation like "/tmp/foo", so make it a strict platform native format by doing 'absolutize' install(node.createLauncher(log), p, new FilePathFileSystem(node), log, expectedLocation.absolutize().getRemote(), file.getRemote()); // successfully installed file.delete(); marker.write(id, null); } catch (DetectionFailedException e) { out.println("JDK installation skipped: "+e.getMessage()); } return expectedLocation; }
install(node.createLauncher(log), p, new FilePathFileSystem(node), log, expectedLocation.absolutize().getRemote(), file.getRemote());
public FilePath performInstallation(ToolInstallation tool, Node node, TaskListener log) throws IOException, InterruptedException { FilePath expectedLocation = preferredLocation(tool, node); PrintStream out = log.getLogger(); try { if(!acceptLicense) { out.println(Messages.JDKInstaller_UnableToInstallUntilLicenseAccepted()); return expectedLocation; } // already installed? FilePath marker = expectedLocation.child(".installedByHudson"); if (marker.exists() && marker.readToString().equals(id)) { return expectedLocation; } expectedLocation.deleteRecursive(); expectedLocation.mkdirs(); Platform p = Platform.of(node); URL url = locate(log, p, CPU.of(node)); out.println("Downloading "+url); FilePath file = expectedLocation.child(p.bundleFileName); file.copyFrom(url); // JDK6u13 on Windows doesn't like path representation like "/tmp/foo", so make it a strict platform native format by doing 'absolutize' install(node.createLauncher(log), p, new FilePathFileSystem(node), log, expectedLocation.absolutize().getRemote(), file.getRemote()); // successfully installed file.delete(); marker.write(id, null); } catch (DetectionFailedException e) { out.println("JDK installation skipped: "+e.getMessage()); } return expectedLocation; }
install(node.createLauncher(log), p, new FilePathFileSystem(node), log, expectedLocation.absolutize().getRemote(), file.getRemote());
if (!scriptFile.absolutize().getRemote().replace('\\', '/').startsWith(dir.absolutize().getRemote().replace('\\', '/') + '/')) { // TODO JENKINS-26838 throw new IOException(scriptFile + " is not inside " + dir);
if (!file.absolutize().getRemote().replace('\\', '/').startsWith(dir.absolutize().getRemote().replace('\\', '/') + '/')) { // TODO JENKINS-26838 throw new IOException(file + " is not inside " + dir);
if (!file.absolutize().getRemote().replace('\\', '/').startsWith(dir.absolutize().getRemote().replace('\\', '/') + '/')) { // TODO JENKINS-26838 throw new IOException(file + " is not inside " + dir);