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

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

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

FilePath.copyFrom介绍

[英]Conveniene method to call FilePath#copyTo(FilePath).
[中]调用FilePath#copyTo(FilePath)的方便方法。

代码示例

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

/**
 * Reads the URL on the current VM, and streams the data to this file using the Remoting channel.
 * <p>This is different from resolving URL remotely.
 * If you instead wished to open an HTTP(S) URL on the remote side,
 * prefer <a href="http://javadoc.jenkins.io/plugin/apache-httpcomponents-client-4-api/io/jenkins/plugins/httpclient/RobustHTTPClient.html#copyFromRemotely-hudson.FilePath-java.net.URL-hudson.model.TaskListener-">{@code RobustHTTPClient.copyFromRemotely}</a>.
 * @since 1.293
 */
public void copyFrom(URL url) throws IOException, InterruptedException {
  try (InputStream in = url.openStream()) {
    copyFrom(in);
  }
}

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

@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

getTargetFilePath(n).copyFrom(u);
if (dynamicLoad)
  pm.dynamicLoad(getTargetFile(n));

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

/**
 * Reads the URL on the current VM, and writes all the data to this {@link FilePath}
 * (this is different from resolving URL remotely.)
 *
 * @since 1.293
 */
public void copyFrom(URL url) throws IOException, InterruptedException {
  try (InputStream in = url.openStream()) {
    copyFrom(in);
  }
}

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

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/selenium-plugin

public String invoke(File f, VirtualChannel channel) throws IOException {
    File conf = new File(f, filename);
    FilePath urlConf = new FilePath(conf);
    try {
      urlConf.copyFrom(new ByteArrayInputStream(config.getBytes()));
    } catch (InterruptedException e) {
      throw new IOException("Failed to write configuration to " + filename, e);
    }
    return conf.getAbsolutePath();
  }
});

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

public String invoke(File f, VirtualChannel channel) throws IOException {
    File conf = new File(f, filename);
    FilePath urlConf = new FilePath(conf);
    try {
      urlConf.copyFrom(new URL(configURL));
    } catch (InterruptedException e) {
      throw new IOException("Failed to retrieve configuration from " + configURL, e);
    }
    return conf.getAbsolutePath();
  }
});

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

protected String extractDefaultReportToWorkingDirectory(FilePath workingDirectory) throws IOException, InterruptedException {
  FilePath defaultConfig = workingDirectory.child(DEFAULT_CONFIG_FILE);
  defaultConfig.copyFrom(getClass().getResourceAsStream(DEFAULT_CONFIG_FILE));
  return defaultConfig.getRemote();
}

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

@Override
public void preOnline(Computer c, Channel channel,FilePath root,  TaskListener listener) throws IOException, InterruptedException {
  PrintStream logger = listener.getLogger();
  copyJar(logger, root, Main.class, "maven-agent");
  copyJar(logger, root, Maven3Main.class, "maven3-agent");
  copyJar(logger, root, Maven3Launcher.class, "maven3-interceptor");
  copyJar(logger, root, AbortException.class, "maven-interceptor");
  copyJar(logger, root, Maven21Interceptor.class, "maven2.1-interceptor");
  copyJar(logger, root, ClassWorld.class, "plexus-classworld");
  
  // copy classworlds 1.1 for maven2 builds
  root.child( "classworlds.jar" ).copyFrom(getClass().getClassLoader().getResource("classworlds.jar"));
  logger.println("Copied classworlds.jar");
}

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

public Map<String, String> saveDownloadedFile(InputStream is, String filePath) throws IOException {
  try {
    FilePath child = workspace.child(filePath);
    child.copyFrom(is);
    return child.act(new DownloadFileCallable(log));
  } catch (InterruptedException e) {
    log.warn("Caught interrupted exception: " + e.getLocalizedMessage());
  } finally {
    IOUtils.closeQuietly(is);
  }
  return null;
}

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

private static List<PerformanceReportParser> getParserWithRelativePath(Run<?, ?> build, FilePath workspace, PrintStream logger, String glob, String percentiles) throws IOException, InterruptedException {
  List<PerformanceReportParser> result = getParserUsingAntPatternRelativePath(build, workspace, logger, glob, percentiles);
  if (result != null && !result.isEmpty()) {
    return result;
  }
  File report = new File(workspace.getRemote() + '/' + glob);
  if (!report.exists()) {
    // if report on remote slave
    FilePath localReport = new FilePath(new File(build.getRootDir(), "/temp/" + glob));
    localReport.copyFrom(new FilePath(workspace, glob));
    return Collections.singletonList(getParser(ParserDetector.detect(localReport.getRemote()), glob, percentiles));
  }
  return Collections.singletonList(getParser(ParserDetector.detect(workspace.getRemote() + '/' + glob), workspace.getRemote() + '/' + glob, percentiles));
}

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

public boolean perform(AbstractBuild<?, ?> build, Launcher launcher, BuildListener listener) throws InterruptedException, IOException {
    build.getWorkspace().child("junit.xml").copyFrom(
      getClass().getResource("junit-report-20090516.xml"));
    return true;
  }
});

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

@Override
  @SuppressWarnings("null")
  public boolean perform(AbstractBuild<?, ?> build, Launcher launcher, BuildListener listener) throws InterruptedException, IOException {
    build.getWorkspace().child("junit.xml").copyFrom(
        getClass().getResource("/hudson/tasks/junit/junit-report-20090516.xml"));
    return true;
  }
});

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

private FilePath copy(VirtualFile src, FilePath dst, TaskListener listener) throws IOException, InterruptedException {
  URL u = src.toExternalURL();
  if (u != null) {
    new RobustHTTPClient().copyFromRemotely(dst, u, listener);
  } else {
    try (InputStream in = src.open()) {
      dst.copyFrom(in);
    }
  }
  return dst;
}

代码示例来源:origin: uber/phabricator-jenkins-plugin

@Override
  public boolean perform(AbstractBuild build, Launcher launcher, BuildListener buildListener) throws
      InterruptedException, IOException {
    build.getWorkspace().child(fileName).copyFrom(resourceClass.getResourceAsStream(resourceName));
    return true;
  }
});

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

private Object convert(String name, ParameterValue v) throws IOException, InterruptedException {
  if (v instanceof FileParameterValue) {
    FileParameterValue fv = (FileParameterValue) v;
    FilePath fp = new FilePath(run.getRootDir()).child(name);
    fp.copyFrom(fv.getFile());
    return fp;
  } else {
    return v.getValue();
  }
}

相关文章