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

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

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

FilePath.child介绍

[英]The same as FilePath#FilePath(FilePath,String) but more OO.
[中]与FilePath#FilePath(FilePath,String)相同,但更多是面向对象的。

代码示例

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

/**
 * Checks if the specified expected location already contains the installed version of the tool.
 *
 * This check needs to run fairly efficiently. The current implementation uses the source URL of {@link Installable},
 * based on the assumption that released bits do not change its content.
 */
protected boolean isUpToDate(FilePath expectedLocation, Installable i) throws IOException, InterruptedException {
  FilePath marker = expectedLocation.child(".installedFrom");
  return marker.exists() && marker.readToString().equals(i.url);
}

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

@Override
public FilePath supplySettings(AbstractBuild<?, ?> build, TaskListener listener) {
  if (StringUtils.isEmpty(path)) {
    return null;
  }
  try {
    EnvVars env = build.getEnvironment(listener);
    String targetPath = Util.replaceMacro(this.path, build.getBuildVariableResolver());
    targetPath = env.expand(targetPath);
    if (IOUtils.isAbsolute(targetPath)) {
      return new FilePath(new File(targetPath));
    } else {
      FilePath mrSettings = build.getModuleRoot().child(targetPath);
      FilePath wsSettings = build.getWorkspace().child(targetPath);
      try {
        if (!wsSettings.exists() && mrSettings.exists()) {
          wsSettings = mrSettings;
        }
      } catch (Exception e) {
        throw new IllegalStateException("failed to find settings.xml at: " + wsSettings.getRemote());
      }
      return wsSettings;
    }
  } catch (Exception e) {
    throw new IllegalStateException("failed to prepare settings.xml");
  }
}

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

@Override
public FilePath supplySettings(AbstractBuild<?, ?> build, TaskListener listener) {
  if (StringUtils.isEmpty(path)) {
    return null;
  }
  try {
    EnvVars env = build.getEnvironment(listener);
    String targetPath = Util.replaceMacro(this.path, build.getBuildVariableResolver());
    targetPath = env.expand(targetPath);
    if (IOUtils.isAbsolute(targetPath)) {
      return new FilePath(new File(targetPath));
    } else {
      FilePath mrSettings = build.getModuleRoot().child(targetPath);
      FilePath wsSettings = build.getWorkspace().child(targetPath);
      try {
        if (!wsSettings.exists() && mrSettings.exists()) {
          wsSettings = mrSettings;
        }
      } catch (Exception e) {
        throw new IllegalStateException("failed to find settings.xml at: " + wsSettings.getRemote());
      }
      return wsSettings;
    }
  } catch (Exception e) {
    throw new IllegalStateException("failed to prepare global settings.xml");
  }
}

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

if(!exists())    // no base directory. can't check
  return FormValidation.ok();
FilePath path = child(value);
if(path.exists()) {
  if (expectingFile) {
    if(!path.isDirectory())

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

private boolean installIfNecessaryFrom(@Nonnull URL archive, @CheckForNull TaskListener listener, @Nonnull String message, int maxRedirects) throws InterruptedException, IOException {
  try {
    FilePath timestamp = this.child(".timestamp");
    long lastModified = timestamp.lastModified();
    URLConnection con;
      if (this.exists()) {
    if(this.exists()) {
      if (lastModified != 0 && sourceTimestamp == lastModified)
        return false;   // already up to date

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

if(!ws.exists()) {// no workspace. can't check
  ok();
  return;
if(ws.child(value).exists()) {
  if (expectingFile) {
    if(!ws.child(value).isDirectory())
      ok();
    else
      error(value+" is not a file");
  } else {
    if(ws.child(value).isDirectory())
      ok();
    else

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

private static FilePath getSpecifications(FilePath candidate)
    throws InterruptedException, IOException {
  FilePath specification = candidate.child("specifications");
  if (specification.exists()) {
    return specification;
  }
  return null;
}

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

private FormValidation validateAbsolutePath(FilePath ws, String path) throws IOException {
  try {
    if (ws.child(path).exists()) {
      return FormValidation.ok();
    }
  } catch (InterruptedException ignore) {
  }
  return FormValidation.error("Error reading ivy settings file: " + path);
}

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

private boolean exists(FilePath base, String file) {
  if (base == null) {
    return false;
  }
  try {
    return base.child(file).exists();
  } catch (IOException ex) {
    LOGGER.warning(ex.getMessage());
  } catch (InterruptedException ex) {
    LOGGER.warning(ex.getMessage());
  }
  return false;
}

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

/**
 * Checks if the specified expected location already contains the installed version of the tool.
 *
 * This check needs to run fairly efficiently. The current implementation uses the source URL of {@link Installable},
 * based on the assumption that released bits do not change its content.
 */
protected boolean isUpToDate(FilePath expectedLocation, Installable i) throws IOException, InterruptedException {
  FilePath marker = expectedLocation.child(".installedFrom");
  return marker.exists() && marker.readToString().equals(i.url);
}

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

/**
 * Checks if the specified expected location already contains the installed version of the tool.
 *
 * This check needs to run fairly efficiently. The current implementation uses the souce URL of {@link Installable},
 * based on the assumption that released bits do not change its content.
 */
protected boolean isUpToDate(FilePath expectedLocation, Installable i) throws IOException, InterruptedException {
  FilePath marker = expectedLocation.child(".installedFrom");
  return marker.exists() && marker.readToString().equals(i.url);
}

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

/**
 * Checks if the specified expected location already contains the installed
 * version of the tool.
 *
 * This check needs to run fairly efficiently. The current implementation
 * uses the souce URL of {@link Installable}, based on the assumption that
 * released bits do not change its content.
 */
protected boolean isUpToDate(FilePath expectedLocation, Installable i) throws IOException, InterruptedException {
  FilePath marker = expectedLocation.child(".installedFrom");
  return marker.exists() && marker.readToString().equals(i.url);
}

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

/**
 * Checks if the specified expected location already contains the installed version of the tool.
 *
 * This check needs to run fairly efficiently. The current implementation uses the souce URL of {@link Installable},
 * based on the assumption that released bits do not change its content.
 */
protected boolean isUpToDate(FilePath expectedLocation, Installable i) throws IOException, InterruptedException {
  FilePath marker = expectedLocation.child(".installedFrom");
  return marker.exists() && marker.readToString().equals(i.url);
}

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

/**
 * Checks if the specified expected location already contains the installed version of the tool.
 *
 * This check needs to run fairly efficiently. The current implementation uses the souce URL of {@link Installable},
 * based on the assumption that released bits do not change its content.
 */
protected boolean isUpToDate(FilePath expectedLocation, Installable i) throws IOException, InterruptedException {
  FilePath marker = expectedLocation.child(".installedFrom");
  return marker.exists() && marker.readToString().equals(i.url);
}

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

private String getJavaBinFromjavaHome(FilePath workingDirectory, String javaHome) throws IOException,
    InterruptedException {
  FilePath javaHomePath = getFilePath(workingDirectory, javaHome);
  if (javaHomePath.exists()) {
    return javaHomePath.child("bin").child("java").getRemote();
  }
  return null;
}

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

public static boolean areNpmPackagesUpToDate(FilePath expected, String npmPackages, long npmPackagesRefreshHours) throws IOException, InterruptedException {
  FilePath marker = expected.child(NPM_PACKAGES_RECORD_FILENAME);
  return marker.exists() && marker.readToString().equals(npmPackages) && System.currentTimeMillis() < marker.lastModified()+ TimeUnit.HOURS.toMillis(npmPackagesRefreshHours);
}

代码示例来源:origin: org.jvnet.hudson.plugins/git

public boolean hasGitModules() throws GitException {
  try {
    FilePath dotGit = workspace.child(".gitmodules");
    return dotGit.exists();
  } catch (SecurityException ex) {
    throw new GitException(
      "Security error when trying to check for .gitmodules. Are you sure you have correct permissions?",
      ex);
  } catch (Exception e) {
    throw new GitException("Couldn't check for .gitmodules", e);
  }
}

代码示例来源:origin: org.jvnet.hudson.plugins/git

public boolean hasGitRepo(String GIT_DIR) throws GitException {
  try {
    FilePath dotGit = workspace.child(GIT_DIR);
    return dotGit.exists();
  } catch (SecurityException ex) {
    throw new GitException(
      "Security error when trying to check for .git. Are you sure you have correct permissions?",
      ex);
  } catch (Exception e) {
    throw new GitException("Couldn't check for .git", e);
  }
}

代码示例来源:origin: org.hudsonci.plugins/git

public boolean hasGitModules() throws GitException {
  try {
    FilePath dotGit = workspace.child(".gitmodules");
    return dotGit.exists();
  } catch (SecurityException ex) {
    throw new GitException(
      "Security error when trying to check for .gitmodules. Are you sure you have correct permissions?", ex);
  } catch (Exception e) {
    throw new GitException("Couldn't check for .gitmodules", e);
  }
}

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

相关文章