hudson.FilePath.<init>()方法的使用及代码示例

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

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

FilePath.<init>介绍

[英]Construct a path starting with a base location.
[中]构造一个从基位置开始的路径。

代码示例

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

/**
 * Returns a {@link FilePath} by adding the given suffix to this path name.
 */
public FilePath withSuffix(String suffix) {
  return new FilePath(channel,remote+suffix);
}

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

@Override
public FilePath createPath(String absolutePath) {
  return new FilePath((VirtualChannel)null,absolutePath);
}

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

/**
 * The same as {@link FilePath#FilePath(FilePath,String)} but more OO.
 * @param relOrAbsolute a relative or absolute path
 * @return a file on the same channel
 */
public @Nonnull FilePath child(String relOrAbsolute) {
  return new FilePath(this,relOrAbsolute);
}

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

@Override
    public FilePath[] invoke(File f, VirtualChannel channel) throws IOException {
      String[] files = glob(reading(f), includes, excludes, defaultExcludes);
      FilePath[] r = new FilePath[files.length];
      for( int i=0; i<r.length; i++ )
        r[i] = new FilePath(new File(f,files[i]));
      return r;
    }
}

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

@Override
  public FilePath call() throws IOException {
    return new FilePath(new File(System.getProperty("user.home")));
  }
}

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

public void write(File to) throws Exception {
  new FilePath(file).copyTo(new FilePath(to));
}

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

@Override
    public List<FilePath> invoke(File f, VirtualChannel channel) throws IOException {
      File[] children = reading(f).listFiles(filter);
      if (children == null) {
        return Collections.emptyList();
      }
      ArrayList<FilePath> r = new ArrayList<FilePath>(children.length);
      for (File child : children)
        r.add(new FilePath(child));
      return r;
    }
}

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

/**
 * Gets the parent file.
 * @return parent FilePath or null if there is no parent
 */
public FilePath getParent() {
  int i = remote.length() - 2;
  for (; i >= 0; i--) {
    char ch = remote.charAt(i);
    if(ch=='\\' || ch=='/')
      break;
  }
  return i >= 0 ? new FilePath( channel, remote.substring(0,i+1) ) : null;
}

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

public FilePath call() throws IOException {
    File home = new File(System.getProperty("user.home"));
    File hudsonHome = new File(home, ".hudson");
    if (hudsonHome.exists()) {
      return new FilePath(new File(hudsonHome, "cli-credentials"));
    }
    return new FilePath(new File(home, ".jenkins/cli-credentials"));
  }
}

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

@Override
public FilePath call() throws IOException {
  final File hprof = File.createTempFile("hudson-heapdump", "hprof");
  hprof.delete();
  try {
    MBeanServer server = ManagementFactory.getPlatformMBeanServer();
    server.invoke(new ObjectName("com.sun.management:type=HotSpotDiagnostic"), "dumpHeap",
        new Object[]{hprof.getAbsolutePath(), true}, new String[]{String.class.getName(), boolean.class.getName()});
    return new FilePath(hprof);
  } catch (JMException e) {
    throw new IOException(e);
  }
}

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

/**
 * Gets the {@link FilePath} on this node.
 */
public @CheckForNull FilePath createPath(String absolutePath) {
  VirtualChannel ch = getChannel();
  if(ch==null)    return null;    // offline
  return new FilePath(ch,absolutePath);
}

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

/**
 * Sets the current directory for the new JVM.
 * This overloaded version only makes sense when you are launching JVM locally.
 */
public JVMBuilder pwd(File pwd) {
  return pwd(new FilePath(pwd));
}

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

private void placeDefaultRule(File f, InputStream src) throws IOException, InterruptedException {
  try {
    new FilePath(f).copyFrom(src);
  } catch (IOException e) {
    // we allow admins to create a read-only file here to block overwrite,
    // so this can fail legitimately
    if (!f.canWrite())  return;
    LOGGER.log(WARNING, "Failed to generate "+f,e);
  }
}

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

private static FilePath getTargetFilePath(String name) {
  return new FilePath(getTargetFile(name));
}

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

@Override public @Nonnull FilePath getRootPath() {
  return new FilePath(getRootDir());
}

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

public ProcStarter pwd(@Nonnull File workDir) {
  return pwd(new FilePath(workDir));
}

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

public void restoreTo(AbstractBuild<?,?> owner, FilePath dst, TaskListener listener) throws IOException, InterruptedException {
    File zip = new File(owner.getRootDir(),"workspace.zip");
    if (zip.exists()) {// we used to keep it in zip
      new FilePath(zip).unzip(dst);
    } else {// but since 1.456 we do tgz
      File tgz = new File(owner.getRootDir(),"workspace.tgz");
      new FilePath(tgz).untar(dst, TarCompression.GZIP);
    }
  }
}

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

@Override public void archive(FilePath workspace, Launcher launcher, BuildListener listener, final Map<String,String> artifacts) throws IOException, InterruptedException {
  File dir = getArtifactsDir();
  String description = "transfer of " + artifacts.size() + " files"; // TODO improve when just one file
  workspace.copyRecursiveTo(new FilePath.ExplicitlySpecifiedDirScanner(artifacts), new FilePath(dir), description);
}

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

/**
 * Absolutizes this {@link FilePath} and returns the new one.
 */
public FilePath absolutize() throws IOException, InterruptedException {
  return new FilePath(channel, act(new Absolutize()));
}
private static class Absolutize extends SecureFileCallable<String> {

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

public FilePath getWorkspaceFor(TopLevelItem item) {
  for (WorkspaceLocator l : WorkspaceLocator.all()) {
    FilePath workspace = l.locate(item, this);
    if (workspace != null) {
      return workspace;
    }
  }
  return new FilePath(expandVariablesForDirectory(workspaceDir, item));
}

相关文章