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

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

本文整理了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

  1. /**
  2. * Performs syntactical check on the remote FS for agents.
  3. */
  4. public FormValidation doCheckRemoteFS(@QueryParameter String value) throws IOException, ServletException {
  5. if(Util.fixEmptyAndTrim(value)==null)
  6. return FormValidation.error(Messages.Slave_Remote_Director_Mandatory());
  7. if(value.startsWith("\\\\") || value.startsWith("/net/"))
  8. return FormValidation.warning(Messages.Slave_Network_Mounted_File_System_Warning());
  9. if (Util.isRelativePath(value)) {
  10. return FormValidation.warning(Messages.Slave_Remote_Relative_Path_Warning());
  11. }
  12. return FormValidation.ok();
  13. }

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

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

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

  1. @Restricted(NoExternalUse.class)
  2. @SuppressWarnings("unused")
  3. public FormValidation doCheckPhysicalPathOnDisk(@QueryParameter String value) {
  4. if (!isRelativePath(value)) {
  5. return FormValidation.error(Messages.formValidation_NotRelativePath());
  6. }
  7. return FormValidation.ok();
  8. }

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

  1. /**
  2. * Normalizes the given custom path and returns it.
  3. *
  4. * @param customPath the workspace path to be used on the disk
  5. * @return the normalized custom path
  6. * @throws IOException if the {@code customPath} is not a relative path, or if it contains any '$' characters,
  7. * meaning that the path was not resolved correctly in the Pipeline script
  8. */
  9. @Nonnull
  10. private String computeCustomPath(@Nonnull String customPath) throws IOException {
  11. if (!isRelativePath(customPath)) {
  12. String message = format("The custom path: %s must be a relative path", customPath);
  13. throw new AbortException(message);
  14. }
  15. if (customPath.contains("${")) {
  16. String message = format("The custom path: %s contains '${' characters. Did you resolve correctly the parameters with Build DSL?", customPath);
  17. throw new AbortException(message);
  18. }
  19. return new FilePath(new File(customPath)).getRemote();
  20. }

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

  1. /**
  2. * Performs syntactical check on the remote FS for agents.
  3. */
  4. public FormValidation doCheckRemoteFS(@QueryParameter String value) throws IOException, ServletException {
  5. if(Util.fixEmptyAndTrim(value)==null)
  6. return FormValidation.error(Messages.Slave_Remote_Director_Mandatory());
  7. if(value.startsWith("\\\\") || value.startsWith("/net/"))
  8. return FormValidation.warning(Messages.Slave_Network_Mounted_File_System_Warning());
  9. if (Util.isRelativePath(value)) {
  10. return FormValidation.warning(Messages.Slave_Remote_Relative_Path_Warning());
  11. }
  12. return FormValidation.ok();
  13. }

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

  1. /**
  2. * Computes the path to be used on the physical disk.
  3. * The computed path has the following pattern: physicalPathOnDisk/$JOB_NAME/$BUILD_NUMBER.
  4. * Where $JOB_NAME also includes all the folders, if Folders plugin is in use.
  5. *
  6. * @param diskId the Disk ID where the physical path on the disk is defined
  7. * @param physicalPathOnDisk the physical path on the disk
  8. * @return the computed file path on the physical disk
  9. * @throws IOException if the {@code physicalPathOnDisk} argument is not a relative path
  10. */
  11. @Nonnull
  12. private String computeDefaultPathOnDisk(@Nonnull String diskId, @CheckForNull String physicalPathOnDisk) throws IOException {
  13. if (physicalPathOnDisk == null) {
  14. physicalPathOnDisk = StringUtils.EMPTY;
  15. }
  16. if (!isRelativePath(physicalPathOnDisk)) {
  17. 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());
  18. throw new AbortException(message);
  19. }
  20. File pathOnDisk = Paths.get(physicalPathOnDisk, run.getParent().getFullName(), String.valueOf(run.getNumber())).toFile();
  21. return new FilePath(pathOnDisk).getRemote();
  22. }

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

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

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

  1. if (!isRelativePath(template)) {
  2. 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

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

相关文章