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

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

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

FilePath.touch介绍

[英]Creates a file (if not already exist) and sets the timestamp.
[中]创建文件(如果不存在)并设置时间戳。

代码示例

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

/**
 * Explodes the plugin into a directory, if necessary.
 */
private static void explode(File archive, File destDir) throws IOException {
  destDir.mkdirs();
  // timestamp check
  File explodeTime = new File(destDir,".timestamp2");
  if(explodeTime.exists() && explodeTime.lastModified()==archive.lastModified())
    return; // no need to expand
  // delete the contents so that old files won't interfere with new files
  Util.deleteRecursive(destDir);
  try {
    Project prj = new Project();
    unzipExceptClasses(archive, destDir, prj);
    createClassJarFromWebInfClasses(archive, destDir, prj);
  } catch (BuildException x) {
    throw new IOException("Failed to expand " + archive,x);
  }
  try {
    new FilePath(explodeTime).touch(archive.lastModified());
  } catch (InterruptedException e) {
    throw new AssertionError(e); // impossible
  }
}

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

timestamp.touch(sourceTimestamp);
      return true;
    } catch (IOException x) {
        archive,cis.getByteCount(),con.getContentLength()),e);
  timestamp.touch(sourceTimestamp);
  return true;
} catch (IOException e) {

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

iapf.touch(System.currentTimeMillis());
iapf.chmod(0640);
iapf.write(randomUUID + System.lineSeparator(), "UTF-8");

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

@Override
  public boolean perform(AbstractBuild<?, ?> build,
      Launcher launcher, BuildListener listener)
      throws InterruptedException, IOException {
    for (FilePath f : build.getWorkspace().list()) {
      f.touch(System.currentTimeMillis());
    }
    return true;
  }
}

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

@Override
  public boolean perform(AbstractBuild<?, ?> build,
              Launcher launcher, BuildListener listener)
      throws InterruptedException, IOException {
    for (FilePath f : build.getWorkspace().list()) {
      f.touch(System.currentTimeMillis());
    }
    return true;
  }
}

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

@Override
  public boolean perform(AbstractBuild<?, ?> build,
              Launcher launcher, BuildListener listener)
      throws InterruptedException, IOException {
    for (FilePath f : build.getWorkspace().list()) {
      f.touch(System.currentTimeMillis());
    }
    return true;
  }
}

代码示例来源:origin: jenkinsci/jenkins-test-harness

@Override
  public boolean perform(AbstractBuild<?, ?> build,
              Launcher launcher, BuildListener listener)
      throws InterruptedException, IOException {
    for (FilePath f : build.getWorkspace().list()) {
      f.touch(System.currentTimeMillis());
    }
    return true;
  }
}

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

@Override
public void convert(File inputFile, File outFile, Map<String, Object> params) throws ConversionException {
  try {
    FileUtils.copyFile(inputFile, outFile);
    new FilePath(outFile).touch(System.currentTimeMillis());
  } catch (IOException ioe) {
    throw new ConversionException(ioe);
  } catch (InterruptedException ie) {
    throw new ConversionException(ie);
  }
}

代码示例来源:origin: jenkinsci/jenkins-test-harness

@Override
public void checkout(Run<?, ?> build, Launcher launcher, FilePath remoteDir, TaskListener listener, File changeLogFile, SCMRevisionState baseline) throws IOException, InterruptedException {
  new FilePath(changeLogFile).touch(0);
  build.addAction(new ChangelogAction(entries, changeLogFile.getName()));
  entries = new ArrayList<EntryImpl>();
}

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

/**
 * Explodes the plugin into a directory, if necessary.
 */
private static void explode(File archive, File destDir) throws IOException {
  destDir.mkdirs();
  // timestamp check
  File explodeTime = new File(destDir,".timestamp2");
  if(explodeTime.exists() && explodeTime.lastModified()==archive.lastModified())
    return; // no need to expand
  // delete the contents so that old files won't interfere with new files
  Util.deleteRecursive(destDir);
  try {
    Project prj = new Project();
    unzipExceptClasses(archive, destDir, prj);
    createClassJarFromWebInfClasses(archive, destDir, prj);
  } catch (BuildException x) {
    throw new IOException("Failed to expand " + archive,x);
  }
  try {
    new FilePath(explodeTime).touch(archive.lastModified());
  } catch (InterruptedException e) {
    throw new AssertionError(e); // impossible
  }
}

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

@Override
  public boolean perform(AbstractBuild<?, ?> build, Launcher launcher, BuildListener listener) throws InterruptedException, IOException {
    FilePath ws = build.getWorkspace();
    // create two files
    ws.child("b").touch(0);
    ws.child("c").touch(0);
    return true;
  }
});

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

/**
 * Explodes the plugin into a directory, if necessary.
 */
private static void explode(File archive, File destDir) throws IOException {
  if(!destDir.exists())
    destDir.mkdirs();
  // timestamp check
  File explodeTime = new File(destDir,".timestamp");
  if(explodeTime.exists() && explodeTime.lastModified()==archive.lastModified())
    return; // no need to expand
  // delete the contents so that old files won't interfere with new files
  Util.deleteContentsRecursive(destDir);
  try {
    Expand e = new Expand();
    e.setProject(new Project());
    e.setTaskType("unzip");
    e.setSrc(archive);
    e.setDest(destDir);
    e.execute();
  } catch (BuildException x) {
    throw new IOException2("Failed to expand " + archive,x);
  }
  try {
    new FilePath(explodeTime).touch(archive.lastModified());
  } catch (InterruptedException e) {
    throw new AssertionError(e); // impossible
  }
}

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

/**
 * Explodes the plugin into a directory, if necessary.
 */
private static void explode(File archive, File destDir) throws IOException {
  if (!destDir.exists()) {
    destDir.mkdirs();
  }
  // timestamp check
  File explodeTime = new File(destDir, ".timestamp");
  if (explodeTime.exists() && explodeTime.lastModified() == archive.lastModified()) {
    return; // no need to expand
  }
  // delete the contents so that old files won't interfere with new files
  Util.deleteContentsRecursive(destDir);
  try {
    Expand e = new Expand();
    e.setProject(new Project());
    e.setTaskType("unzip");
    e.setSrc(archive);
    e.setDest(destDir);
    e.execute();
  } catch (BuildException x) {
    throw new IOException2("Failed to expand " + archive, x);
  }
  try {
    new FilePath(explodeTime).touch(archive.lastModified());
  } catch (InterruptedException e) {
    throw new AssertionError(e); // impossible
  }
}

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

private ConanClient getConanClient() throws Exception {
  ConanClient conanClient = step.getClient();
  FilePath conanHomeDirectory;
  if (StringUtils.isEmpty(conanClient.getUserPath())) {
    conanHomeDirectory = env.containsKey(Utils.CONAN_USER_HOME) ? new FilePath(new File(env.get(Utils.CONAN_USER_HOME))) : createConanTempHome();
  } else {
    conanHomeDirectory = new FilePath(launcher.getChannel(), conanClient.getUserPath());
    if (!conanHomeDirectory.exists()) {
      conanHomeDirectory.mkdirs();
    }
  }
  conanClient.setUserPath(conanHomeDirectory.getRemote());
  conanHomeDirectory.child(ConanClient.CONAN_LOG_FILE).touch(Calendar.getInstance().getTimeInMillis());
  return conanClient;
}

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

private void addFiles(String... paths) throws Exception {
SvnClientManager svnm = SubversionSCM.createClientManager((AbstractProject) null);
for (String path : paths) {
  FilePath newFile = workingcopy.child(path);
  newFile.touch(System.currentTimeMillis());
  svnm.getWCClient().doAdd(new File(newFile.getRemote()), false, false, false, SVNDepth.INFINITY, false, false);
}
}

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

@Override
  public boolean perform(AbstractBuild<?, ?> build,
              Launcher launcher, BuildListener listener)
      throws InterruptedException, IOException {
    System.out.println("in perform...");
    // First touch all the files, so they will be recently modified
    for (FilePath f : build.getWorkspace().list()) {
      f.touch(System.currentTimeMillis());
    }
    System.out.println("...touched everything");
    hudson.tasks.junit.TestResult result = (new JUnitParser()).parseResult(testResultLocation, build,
        null, build.getWorkspace(), launcher, listener);
    System.out.println("back from parse");
    assertNotNull("we should have a non-null result", result);
    assertTrue("result should be a TestResult", result instanceof hudson.tasks.junit.TestResult);
    System.out.println("We passed some assertions in the JUnitParserTestBuilder");
    theResult = result;
    return result != null;
  }
}

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

public void touchAndCommit(FilePath repo, String... names) throws Exception {
  for (String name : names) {
    FilePath toTouch = repo.child(name);
    if (!toTouch.exists()) {
      toTouch.getParent().mkdirs();
      toTouch.touch(0);
      hg(repo, "add", name);
    } else {
      toTouch.write(toTouch.readToString() + "extra line\n", "UTF-8");
    }
  }
  hg(repo, "commit", "--message", "added " + Arrays.toString(names));
}

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

/**
 * Manufactures commits by adding files in the given names.
 */
private void createCommit(SubversionSCM scm, String... paths) throws Exception {
  FreeStyleProject forCommit = r.createFreeStyleProject();
  forCommit.setScm(scm);
  forCommit.setAssignedLabel(r.jenkins.getSelfLabel());
  FreeStyleBuild b = r.assertBuildStatusSuccess(forCommit.scheduleBuild2(0).get());
  SvnClientManager svnm = SubversionSCM.createClientManager((AbstractProject)null);
  List<File> added = new ArrayList<>();
  for (String path : paths) {
    FilePath newFile = b.getWorkspace().child(path);
    added.add(new File(newFile.getRemote()));
    if (!newFile.exists()) {
      newFile.touch(System.currentTimeMillis());
      svnm.getWCClient().doAdd(new File(newFile.getRemote()),false,false,false, SVNDepth.INFINITY, false,false);
    } else
      newFile.write("random content","UTF-8");
  }
  SVNCommitClient cc = svnm.getCommitClient();
  cc.doCommit(added.toArray(new File[added.size()]),false,"added",null,null,false,false,SVNDepth.EMPTY);
}

相关文章