本文整理了Java中hudson.FilePath.absolutize()
方法的一些代码示例,展示了FilePath.absolutize()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。FilePath.absolutize()
方法的具体详情如下:
包路径:hudson.FilePath
类名称:FilePath
方法名:absolutize
[英]Absolutizes this FilePath and returns the new one.
[中]将此文件路径绝对化并返回新文件路径。
代码示例来源:origin: jenkinsci/shiningpanda-plugin
/**
* 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());
}
代码示例来源:origin: jenkinsci/mesos-plugin
@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;
}
代码示例来源:origin: awslabs/aws-codedeploy-plugin
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;
}
代码示例来源:origin: jenkinsci/ghprb-plugin
} else {
listener.getLogger().println(
"Didn't find comment file in workspace at " + path.absolutize().getRemote()
+ ", falling back to file operations on master."
);
代码示例来源:origin: superfell/JenkinsChatterPlugin
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);
代码示例来源:origin: jenkinsci/artifactory-plugin
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;
}
代码示例来源:origin: org.jenkins-ci.plugins/collabnet
/**
* 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;
}
代码示例来源:origin: org.jenkins-ci.plugins/collabnet
try {
uploadFilePaths = workspace.list(pattern);
logEntry += " in " + workspace.absolutize().getRemote();
} catch (IOException ioe) {
this.logConsole("Could not list workspace due to IOException: "
代码示例来源:origin: org.jvnet.hudson.main/hudson-core
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;
}
代码示例来源:origin: org.jvnet.hudson.plugins/clearcase
if (option == SetcsOption.CONFIGSPEC) {
configSpecFile = launcher.getWorkspace().createTextTempFile("configspec", ".txt", configSpec);
cmd.add(PathUtil.convertPathForOS(configSpecFile.absolutize().getRemote(), launcher.getLauncher().isUnix()));
代码示例来源:origin: jenkinsci/artifactory-plugin
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());
}
}
代码示例来源:origin: hudson/hudson-2.x
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;
}
代码示例来源:origin: org.eclipse.hudson/hudson-core
install(node.createLauncher(log), p, new FilePathFileSystem(node), log, expectedLocation.absolutize().getRemote(), file.getRemote());
代码示例来源:origin: org.eclipse.hudson.main/hudson-core
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;
}
代码示例来源:origin: org.jenkins-ci.main/jenkins-core
install(node.createLauncher(log), p, new FilePathFileSystem(node), log, expectedLocation.absolutize().getRemote(), file.getRemote());
代码示例来源:origin: jenkinsci/workflow-cps-plugin
if (!scriptFile.absolutize().getRemote().replace('\\', '/').startsWith(dir.absolutize().getRemote().replace('\\', '/') + '/')) { // TODO JENKINS-26838
throw new IOException(scriptFile + " is not inside " + dir);
代码示例来源:origin: jenkinsci/workflow-multibranch-plugin
if (!file.absolutize().getRemote().replace('\\', '/').startsWith(dir.absolutize().getRemote().replace('\\', '/') + '/')) { // TODO JENKINS-26838
throw new IOException(file + " is not inside " + dir);
代码示例来源:origin: org.jenkins-ci.plugins.workflow/workflow-multibranch
if (!file.absolutize().getRemote().replace('\\', '/').startsWith(dir.absolutize().getRemote().replace('\\', '/') + '/')) { // TODO JENKINS-26838
throw new IOException(file + " is not inside " + dir);
内容来源于网络,如有侵权,请联系作者删除!