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

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

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

FilePath.createTempFile介绍

[英]Creates a temporary file in the directory that this FilePath object designates.
[中]在此FilePath对象指定的目录中创建临时文件。

代码示例

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

public FilePath buildArchive(FilePath workspace) throws IOException, InterruptedException {
  final FilePath outputFile = workspace.createTempFile("docker", ".tar.gz");
  try (TarArchiveOutputStream out = new TarArchiveOutputStream(new GZIPOutputStream(outputFile.write()))) {
    ObjectNode auths = buildAuthsObject();
    JsonNode config = MAPPER.createObjectNode().set("auths", auths);
    byte[] bytes = config.toString().getBytes(Constants.DEFAULT_CHARSET);
    TarArchiveEntry entry = new TarArchiveEntry(".docker/config.json");
    entry.setSize(bytes.length);
    out.putArchiveEntry(entry);
    out.write(bytes);
    out.closeArchiveEntry();
  }
  return outputFile;
}

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

/**
 * Extracts Ant and configures it.
 */
protected Ant.AntInstallation configureDefaultAnt() throws Exception {
  Ant.AntInstallation antInstallation;
  if (System.getenv("ANT_HOME") != null) {
    antInstallation = new AntInstallation("default", System.getenv("ANT_HOME"), NO_PROPERTIES);
  } else {
    LOGGER.warning("Extracting a copy of Ant bundled in the test harness. " +
        "To avoid a performance hit, set the environment variable ANT_HOME to point to an  Ant installation.");
    FilePath ant = hudson.getRootPath().createTempFile("ant", "zip");
    ant.copyFrom(HudsonTestCase.class.getClassLoader().getResource("apache-ant-1.8.1-bin.zip"));
    File antHome = createTmpDir();
    ant.unzip(new FilePath(antHome));
    // TODO: switch to tar that preserves file permissions more easily
    if(!Functions.isWindows())
      GNUCLibrary.LIBC.chmod(new File(antHome,"apache-ant-1.8.1/bin/ant").getPath(),0755);
    antInstallation = new AntInstallation("default", new File(antHome,"apache-ant-1.8.1").getAbsolutePath(),NO_PROPERTIES);
  }
  hudson.getDescriptorByType(Ant.DescriptorImpl.class).setInstallations(antInstallation);
  return antInstallation;
}

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

private FilePath fetchConfig(FilePath workspace) throws Exception {
    SSHClient sshClient = new SSHClient(host, port, credentials);
    try (SSHClient ignore = sshClient.connect()) {
      FilePath configFile = workspace.createTempFile(Constants.KUBECONFIG_PREFIX, "");
      try (OutputStream out = configFile.write()) {
        sshClient.copyFrom(Constants.KUBECONFIG_FILE, out);
      }
      return configFile;
    }
  }
}

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

/**
 * Extracts Ant and configures it.
 */
protected Ant.AntInstallation configureDefaultAnt() throws Exception {
  Ant.AntInstallation antInstallation;
  if (System.getenv("ANT_HOME") != null) {
    antInstallation = new AntInstallation("default", System.getenv("ANT_HOME"), NO_PROPERTIES);
  } else {
    LOGGER.warning("Extracting a copy of Ant bundled in the test harness. " +
        "To avoid a performance hit, set the environment variable ANT_HOME to point to an  Ant installation.");
    FilePath ant = hudson.getRootPath().createTempFile("ant", "zip");
    ant.copyFrom(HudsonTestCase.class.getClassLoader().getResource("apache-ant-1.8.1-bin.zip"));
    File antHome = createTmpDir();
    ant.unzip(new FilePath(antHome));
    // TODO: switch to tar that preserves file permissions more easily
    if(!Functions.isWindows())
      GNUCLibrary.LIBC.chmod(new File(antHome,"apache-ant-1.8.1/bin/ant").getPath(),0755);
    antInstallation = new AntInstallation("default", new File(antHome,"apache-ant-1.8.1").getAbsolutePath(),NO_PROPERTIES);
  }
  hudson.getDescriptorByType(Ant.DescriptorImpl.class).setInstallations(antInstallation);
  return antInstallation;
}

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

/**
 * Extracts Ant and configures it.
 */
protected Ant.AntInstallation configureDefaultAnt() throws Exception {
  Ant.AntInstallation antInstallation;
  if (System.getenv("ANT_HOME") != null) {
    antInstallation = new AntInstallation("default", System.getenv("ANT_HOME"), NO_PROPERTIES);
  } else {
    LOGGER.warning("Extracting a copy of Ant bundled in the test harness. "
        + "To avoid a performance hit, set the environment variable ANT_HOME to point to an  Ant installation.");
    FilePath ant = hudson.getRootPath().createTempFile("ant", "zip");
    ant.copyFrom(HudsonTestCase.class.getClassLoader().getResource("apache-ant-1.8.1-bin.zip"));
    File antHome = createTmpDir();
    ant.unzip(new FilePath(antHome));
    // TODO: switch to tar that preserves file permissions more easily
    if (!Functions.isWindows()) {
      Util.chmod(new File(antHome, "apache-ant-1.8.1/bin/ant"), 0755);
    }
    antInstallation = new AntInstallation("default", new File(antHome, "apache-ant-1.8.1").getAbsolutePath(), NO_PROPERTIES);
  }
  hudson.getDescriptorByType(Ant.DescriptorImpl.class).setInstallations(antInstallation);
  return antInstallation;
}

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

FilePath mvn = hudson.getRootPath().createTempFile("maven", "zip");
mvn.copyFrom(HudsonTestCase.class.getClassLoader().getResource(mavenVersion + "-bin.zip"));
File mvnHome =  new File(buildDirectory);//createTmpDir();

代码示例来源:origin: jenkinsci/debian-package-builder-plugin

private FilePath[] generateDuploadConf(AbstractBuild<?, ?> build, Runner runner) throws IOException, InterruptedException, DebianizingException {
  String confTemplate =
      "package config;\n\n" +
      "$default_host = '${name}';\n\n" +
      "$cfg{'${name}'} = {\n" +
      "\tlogin => '${login}',\n" +
      "\tfqdn => '${fqdn}',\n" +
      "\tmethod => '${method}',\n" +
      "\tincoming => '${incoming}',\n" +
      "\tdinstall_runs => 0,\n" +
      "\toptions => '${options}',\n" +
      "};\n\n" +
      "1;\n";
  Map<String, String> values = new HashMap<String, String>();
  DebianPackageRepo repo = getRepo(build, runner);
  FilePath keyPath = getRemoteKeyPath(build, runner);
  values.put("name", repo.getName());
  values.put("method", repo.getMethod());
  values.put("fqdn", repo.getFqdn());
  values.put("incoming", repo.getIncoming());
  values.put("login", repo.getLogin());
  values.put("options", MessageFormat.format("-i {0} ", keyPath.getRemote()) + repo.getOptions());
  StrSubstitutor substitutor = new StrSubstitutor(values);
  String conf = substitutor.replace(confTemplate);
  FilePath duploadConf = build.getWorkspace().createTempFile("dupload", "conf");
  duploadConf.touch(System.currentTimeMillis()/1000);
  duploadConf.write(conf, "UTF-8");
  return new FilePath[] { duploadConf, keyPath };
}

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

FilePath mvn = hudson.getRootPath().createTempFile("maven", "zip");
mvn.copyFrom(HudsonTestCase.class.getClassLoader().getResource(mavenVersion + "-bin.zip"));
File mvnHome =  new File(buildDirectory);//createTmpDir();

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

FilePath mvn = hudson.getRootPath().createTempFile("maven", "zip");
mvn.copyFrom(HudsonTestCase.class.getClassLoader().getResource(mavenVersion + "-bin.zip"));
File mvnHome = new File(buildDirectory);//createTmpDir();

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

throw new IOException(node.getDisplayName() + " is offline");
sshPrivateKey = slaveRoot.createTempFile("jenkins-mercurial", ".sshkey");
sshPrivateKey.chmod(0600);

代码示例来源:origin: org.jenkins-ci.plugins/config-file-provider

target = workDir.createTempFile("config", "tmp");
} else {

代码示例来源:origin: carlossg/jenkins-kubernetes-plugin

@Override
public void setUp(Context context, Run<?, ?> build, FilePath workspace, Launcher launcher, TaskListener listener, EnvVars initialEnvironment) throws IOException, InterruptedException {
  FilePath configFile = workspace.createTempFile(".kube", "config");
  Set<String> tempFiles = newHashSet(configFile.getRemote());
    FilePath caCrtFile = workspace.createTempFile("cert-auth", "crt");
    String ca = caCertificate;
    if (!ca.startsWith(BEGIN_CERTIFICATE)) {
      X509Certificate certificate = (X509Certificate) keyStore.getCertificate(alias);
      Key key = keyStore.getKey(alias, Secret.toString(scc.getPassword()).toCharArray());
      FilePath clientCrtFile = workspace.createTempFile("client", "crt");
      FilePath clientKeyFile = workspace.createTempFile("client", "key");
      String encodedClientCrt = wrapWithMarker(BEGIN_CERTIFICATE, END_CERTIFICATE,
          Base64.encodeBase64String(certificate.getEncoded()));

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

String logFile = parent.createTempFile("install", "log").getRemote();

相关文章