hudson.FilePath.getParent()方法的使用及代码示例

x33g5p2x  于2022-01-19 转载在 其他  
字(7.6k)|赞(0)|评价(0)|浏览(132)

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

FilePath.getParent介绍

[英]Gets the parent file.
[中]获取父文件。

代码示例

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

/**
 * Short for {@code getParent().child(rel)}. Useful for getting other files in the same directory. 
 */
public FilePath sibling(String rel) {
  return getParent().child(rel);
}

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

@Override public VirtualFile getParent() {
  return f.getParent().toVirtualFile();
}
@Override public boolean isDirectory() throws IOException {

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

/**
   * 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;
  }
}

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

@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() {};
  }
};

代码示例来源:origin: org.jvnet.hudson.main/hudson-core

/**
 * Short for {@code getParent().child(rel)}. Useful for getting other files in the same directory. 
 */
public FilePath sibling(String rel) {
  return getParent().child(rel);
}

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

/**
 * Short for {@code getParent().child(rel)}. Useful for getting other files in the same directory. 
 */
public FilePath sibling(String rel) {
  return getParent().child(rel);
}

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

@Override public VirtualFile getParent() {
  return f.getParent().toVirtualFile();
}
@Override public boolean isDirectory() throws IOException {

代码示例来源:origin: org.eclipse.hudson/hudson-core

/**
 * Short for {@code getParent().child(rel)}. Useful for getting other files
 * in the same directory.
 */
public FilePath sibling(String rel) {
  return getParent().child(rel);
}

代码示例来源:origin: org.eclipse.hudson.main/hudson-core

/**
 * Short for {@code getParent().child(rel)}. Useful for getting other files in the same directory. 
 */
public FilePath sibling(String rel) {
  return getParent().child(rel);
}

代码示例来源:origin: awslabs/aws-codedeploy-plugin

private boolean isSubDirectory(FilePath parent, FilePath child) {
  FilePath parentFolder = child;
  while (parentFolder!=null) {
    if (parent.equals(parentFolder)) {
      return true;
    }
    parentFolder = parentFolder.getParent();
  }
  return false;
}

代码示例来源:origin: hudson/hudson-2.x

/**
 * Short for {@code getParent().child(rel)}. Useful for getting other files in the same directory. 
 */
public FilePath sibling(String rel) {
  return getParent().child(rel);
}

代码示例来源:origin: org.jenkins-ci.plugins/cloverphp

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);
}

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

@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() {};
  }
};

代码示例来源:origin: org.jenkins-ci.plugins/cloverphp

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;
}

代码示例来源:origin: org.eclipse.hudson.main/hudson-core

@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() {};
  }
};

代码示例来源:origin: org.eclipse.hudson/hudson-core

@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() {
    };
  }
};

代码示例来源:origin: org.jvnet.hudson.main/hudson-core

@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() {};
  }
};

代码示例来源:origin: hudson/hudson-2.x

@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() {};
  }
};

代码示例来源:origin: org.jenkins-ci.plugins/pipeline-utility-steps

@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);
  }
}

代码示例来源:origin: jenkinsci/pipeline-utility-steps-plugin

@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);
  }
}

相关文章