hudson.Util.isRelativePath()方法的使用及代码示例

x33g5p2x  于2022-01-31 转载在 其他  
字(4.6k)|赞(0)|评价(0)|浏览(133)

本文整理了Java中hudson.Util.isRelativePath()方法的一些代码示例,展示了Util.isRelativePath()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Util.isRelativePath()方法的具体详情如下:
包路径:hudson.Util
类名称:Util
方法名:isRelativePath

Util.isRelativePath介绍

[英]A mostly accurate check of whether a path is a relative path or not. This is designed to take a path against an unknown operating system so may give invalid results.
[中]对路径是否为相对路径的最准确的检查。这是为了针对未知的操作系统选择一条路径,因此可能会给出无效的结果。

代码示例

代码示例来源:origin: jenkinsci/jenkins

/**
 * Performs syntactical check on the remote FS for agents.
 */
public FormValidation doCheckRemoteFS(@QueryParameter String value) throws IOException, ServletException {
  if(Util.fixEmptyAndTrim(value)==null)
    return FormValidation.error(Messages.Slave_Remote_Director_Mandatory());
  if(value.startsWith("\\\\") || value.startsWith("/net/"))
    return FormValidation.warning(Messages.Slave_Network_Mounted_File_System_Warning());
  if (Util.isRelativePath(value)) {
    return FormValidation.warning(Messages.Slave_Remote_Relative_Path_Warning());
  }
  return FormValidation.ok();
}

代码示例来源:origin: jenkinsci/jenkins

if (Util.isRelativePath(remoteFS)) {
  remoteFS = channel.call(new AbsolutePath(remoteFS));
  log.println("NOTE: Relative remote path resolved to: "+remoteFS);

代码示例来源:origin: jenkinsci/external-workspace-manager-plugin

@Restricted(NoExternalUse.class)
@SuppressWarnings("unused")
public FormValidation doCheckPhysicalPathOnDisk(@QueryParameter String value) {
  if (!isRelativePath(value)) {
    return FormValidation.error(Messages.formValidation_NotRelativePath());
  }
  return FormValidation.ok();
}

代码示例来源:origin: jenkinsci/external-workspace-manager-plugin

/**
 * Normalizes the given custom path and returns it.
 *
 * @param customPath the workspace path to be used on the disk
 * @return the normalized custom path
 * @throws IOException if the {@code customPath} is not a relative path, or if it contains any '$' characters,
 *                     meaning that the path was not resolved correctly in the Pipeline script
 */
@Nonnull
private String computeCustomPath(@Nonnull String customPath) throws IOException {
  if (!isRelativePath(customPath)) {
    String message = format("The custom path: %s must be a relative path", customPath);
    throw new AbortException(message);
  }
  if (customPath.contains("${")) {
    String message = format("The custom path: %s contains '${' characters. Did you resolve correctly the parameters with Build DSL?", customPath);
    throw new AbortException(message);
  }
  return new FilePath(new File(customPath)).getRemote();
}

代码示例来源:origin: org.jenkins-ci.main/jenkins-core

/**
 * Performs syntactical check on the remote FS for agents.
 */
public FormValidation doCheckRemoteFS(@QueryParameter String value) throws IOException, ServletException {
  if(Util.fixEmptyAndTrim(value)==null)
    return FormValidation.error(Messages.Slave_Remote_Director_Mandatory());
  if(value.startsWith("\\\\") || value.startsWith("/net/"))
    return FormValidation.warning(Messages.Slave_Network_Mounted_File_System_Warning());
  if (Util.isRelativePath(value)) {
    return FormValidation.warning(Messages.Slave_Remote_Relative_Path_Warning());
  }
  return FormValidation.ok();
}

代码示例来源:origin: jenkinsci/external-workspace-manager-plugin

/**
 * Computes the path to be used on the physical disk.
 * The computed path has the following pattern: physicalPathOnDisk/$JOB_NAME/$BUILD_NUMBER.
 * Where $JOB_NAME also includes all the folders, if Folders plugin is in use.
 *
 * @param diskId             the Disk ID where the physical path on the disk is defined
 * @param physicalPathOnDisk the physical path on the disk
 * @return the computed file path on the physical disk
 * @throws IOException if the {@code physicalPathOnDisk} argument is not a relative path
 */
@Nonnull
private String computeDefaultPathOnDisk(@Nonnull String diskId, @CheckForNull String physicalPathOnDisk) throws IOException {
  if (physicalPathOnDisk == null) {
    physicalPathOnDisk = StringUtils.EMPTY;
  }
  if (!isRelativePath(physicalPathOnDisk)) {
    String message = format("Physical path on disk defined for Disk ID '%s', within Disk Pool ID '%s' must be a relative path", diskId, step.getDiskPoolId());
    throw new AbortException(message);
  }
  File pathOnDisk = Paths.get(physicalPathOnDisk, run.getParent().getFullName(), String.valueOf(run.getNumber())).toFile();
  return new FilePath(pathOnDisk).getRemote();
}

代码示例来源:origin: jenkinsci/external-workspace-manager-plugin

Set<String> existingMessages = new HashSet<>();
if (!Util.isRelativePath(value)) {
  formValidations.add(error(Messages.formValidation_NotRelativePath()));

代码示例来源:origin: jenkinsci/external-workspace-manager-plugin

if (!isRelativePath(template)) {
  throw new AbortException(format("Workspace template defined for Disk Pool '%s' must be a relative path", step.getDiskPoolId()));

代码示例来源:origin: org.jenkins-ci.main/jenkins-core

if (Util.isRelativePath(remoteFS)) {
  remoteFS = channel.call(new AbsolutePath(remoteFS));
  log.println("NOTE: Relative remote path resolved to: "+remoteFS);

相关文章

微信公众号

最新文章

更多