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

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

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

FilePath.mkdirs介绍

[英]Creates this directory.
[中]创建此目录。

代码示例

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

/**
 * Writes to this file.
 * If this file already exists, it will be overwritten.
 * If the directory doesn't exist, it will be created.
 *
 * <P>
 * I/O operation to remote {@link FilePath} happens asynchronously, meaning write operations to the returned
 * {@link OutputStream} will return without receiving a confirmation from the remote that the write happened.
 * I/O operations also happens asynchronously from the {@link Channel#call(Callable)} operations, so if
 * you write to a remote file and then execute {@link Channel#call(Callable)} and try to access the newly copied
 * file, it might not be fully written yet.
 *
 * <p>
 *
 */
public OutputStream write() throws IOException, InterruptedException {
  if(channel==null) {
    File f = new File(remote).getAbsoluteFile();
    mkdirs(f.getParentFile());
    return Files.newOutputStream(fileToPath(writing(f)));
  }
  return act(new WritePipe());
}
private class WritePipe extends SecureFileCallable<OutputStream> {

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

mkdirs(f);
} else {
  File p = f.getParentFile();
  if (p != null) {
    mkdirs(p);

代码示例来源: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: jenkinsci/jenkins

mkdirs(f);
} else {
  File parent = f.getParentFile();
  if (parent != null) mkdirs(parent);
  writing(f);

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

this.deleteContents();
} else {
  this.mkdirs();

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

public boolean checkout(AbstractBuild build, Launcher launcher, BuildListener listener, File changelogFile) throws IOException, InterruptedException {
  SCM scm = getScm();
  if(scm==null)
    return true;    // no SCM
  FilePath workspace = build.getWorkspace();
  if(workspace!=null){
    workspace.mkdirs();
  } else {
    throw new AbortException("Cannot checkout SCM, workspace is not defined");
  }
  boolean r = scm.checkout(build, launcher, workspace, listener, changelogFile);
  if (r) {
    // Only calcRevisionsFromBuild if checkout was successful. Note that modern SCM implementations
    // won't reach this line anyway, as they throw AbortExceptions on checkout failure.
    calcPollingBaseline(build, launcher, listener);
  }
  return r;
}

代码示例来源:origin: jenkinsci/warnings-ng-plugin

private FilePath createBuildDirectory(final FilePath jenkinsBuildRoot)
    throws IOException, InterruptedException {
  FilePath directory = jenkinsBuildRoot.child(AFFECTED_FILES_FOLDER_NAME);
  try {
    directory.mkdirs();
  }
  catch (IOException exception) {
    throw new IOException("Can't create directory for workspace files that contain issues: "
        + directory.getName(), exception);
  }
  return directory;
}

代码示例来源:origin: jenkinsci/performance-plugin

private FilePath createTemporaryWorkspace(Run<?, ?> run, FilePath workspace, PrintStream logger) throws Exception {
  logger.println("[WARNING] Performance test: Job workspace contains spaces in path. Virtualenv does not support such path. Creating temporary workspace for virtualenv.");
  File baseTmpDir = new File(System.getProperty("java.io.tmpdir"));
  if (baseTmpDir.getAbsolutePath().contains(" ")) {
    logger.println("[WARNING] Performance test: Temporary folder contains spaces in path.");
    throw new InvalidPathException(baseTmpDir.getAbsolutePath(), "Virtualenv cannot be installed in workspace that contains spaces in path.");
  }
  File tempDir = new File(baseTmpDir.getAbsolutePath(), "perf-test-virtualenv-workspace-" + configJobName(run.getParent().getName()));
  FilePath tempWorkspace = new FilePath(workspace.getChannel(), tempDir.getAbsolutePath());
  tempWorkspace.mkdirs();
  return tempWorkspace;
}

代码示例来源:origin: jenkinsci/jacoco-plugin

public int saveSourcesFrom(@Nonnull FilePath dir, @Nonnull String inclusionMask, @Nonnull String exclusionMask) throws IOException, InterruptedException {
  FilePath d = new FilePath(getSourcesDir());
  d.mkdirs();
  return dir.copyRecursiveTo(inclusionMask, exclusionMask, d);
}

代码示例来源:origin: jenkinsci/copyartifact-plugin

private static Map<String, String> copy(FilePath targetDir, VirtualFile srcDir, String expandedFilter, String expandedExcludes, boolean fingerprint, TaskListener listener, boolean flatten) throws IOException, InterruptedException {
  targetDir.mkdirs();  // Create target if needed
  Collection<String> list = srcDir.list(expandedFilter.replace('\\', '/'), expandedExcludes != null ? expandedExcludes.replace('\\', '/') : null, false);
  Map<String, String> fingerprints = new HashMap<>();
  for (String entry : list) {
    String digest = copyOne(srcDir.child(entry), new FilePath(targetDir, flatten ? entry.replaceFirst(".+/", "") : entry), fingerprint, listener);
    fingerprints.put(entry, digest);
  }
  return fingerprints;
}

代码示例来源:origin: jenkinsci/jacoco-plugin

public int saveClassesFrom(@Nonnull FilePath dir, @Nonnull String fileMask) throws IOException, InterruptedException {
  FilePath d = new FilePath(getClassesDir());
  d.mkdirs();
  return dir.copyRecursiveTo(fileMask, d);
}

代码示例来源:origin: jenkinsci/copyartifact-plugin

@Override
public int copyAll(FilePath srcDir, String filter, String excludes, FilePath targetDir, boolean fingerprintArtifacts) throws IOException, InterruptedException {
  targetDir.mkdirs();  // Create target if needed
  FilePath[] list = srcDir.list(filter, excludes, false);
  for (FilePath file : list) {
    String tail = file.getRemote().substring(srcDir.getRemote().length());
    if (tail.startsWith("\\") || tail.startsWith("/"))
      tail = tail.substring(1);
    copyOne(file, new FilePath(targetDir, tail), fingerprintArtifacts);
  }
  return list.length;
}

代码示例来源: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: hudson/hudson-2.x

public boolean checkout(AbstractBuild build, Launcher launcher, BuildListener listener, File changelogFile) throws IOException, InterruptedException {
  SCM scm = getScm();
  if(scm==null)
    return true;    // no SCM
  FilePath workspace = build.getWorkspace();
  workspace.mkdirs();
  boolean r = scm.checkout(build, launcher, workspace, listener, changelogFile);
  calcPollingBaseline(build, launcher, listener);
  return r;
}

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

public boolean checkout(AbstractBuild build, Launcher launcher, BuildListener listener, File changelogFile) throws IOException, InterruptedException {
  SCM scm = getScm();
  if (scm == null) {
    return true;    // no SCM
  }
  FilePath workspace = build.getWorkspace();
  workspace.mkdirs();
  boolean r = scm.checkout(build, launcher, workspace, listener, changelogFile);
  calcPollingBaseline(build, launcher, listener);
  return r;
}

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

public boolean checkout(AbstractBuild build, Launcher launcher, BuildListener listener, File changelogFile) throws IOException, InterruptedException {
  SCM scm = getScm();
  if (scm == null) {
    return true;    // no SCM
  }
  FilePath workspace = build.getWorkspace();
  workspace.mkdirs();
  boolean r = scm.checkout(build, launcher, workspace, listener, changelogFile);
  calcPollingBaseline(build, launcher, listener);
  return r;
}

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

public boolean checkout(AbstractBuild build, Launcher launcher, BuildListener listener, File changelogFile) throws IOException, InterruptedException {
  SCM scm = getScm();
  if(scm==null)
    return true;    // no SCM
  FilePath workspace = build.getWorkspace();
  workspace.mkdirs();
  boolean r = scm.checkout(build, launcher, workspace, listener, changelogFile);
  calcPollingBaseline(build, launcher, listener);
  return r;
}

代码示例来源: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);
  }
}

代码示例来源:origin: jenkinsci/workflow-basic-steps-plugin

@Override protected Void run() throws Exception {
  FilePath workspace = getContext().get(FilePath.class);
  workspace.mkdirs();
  delegate.perform(getContext().get(Run.class), workspace, getContext().get(Launcher.class), getContext().get(TaskListener.class));
  return null;
}

相关文章