hudson.Util.createSymlink()方法的使用及代码示例

x33g5p2x  于2022-01-31 转载在 其他  
字(8.0k)|赞(0)|评价(0)|浏览(142)

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

Util.createSymlink介绍

[英]Creates a symlink to targetPath at baseDir+symlinkPath.

If there's a prior symlink at baseDir+symlinkPath, it will be overwritten.
[中]

代码示例

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

@Override
  public Void invoke(File f, VirtualChannel channel) throws IOException, InterruptedException {
    symlinking(f);
    Util.createSymlink(f.getParentFile(), target, f.getName(), listener);
    return null;
  }
}

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

@Override
  public void visitSymlink(File link, String target, String relativePath) throws IOException {
    try {
      mkdirsE(new File(dest, relativePath).getParentFile());
      writing(new File(dest, target));
      Util.createSymlink(dest, target, relativePath, TaskListener.NULL);
    } catch (InterruptedException x) {
      throw new IOException(x);
    }
    count.incrementAndGet();
  }
}));

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

System.err.println(build + " could not be renamed");
Util.createSymlink(builds, id, Integer.toString(number), StreamTaskListener.fromStderr());

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

/**
 * Remembers the value 'n' in the cache for future {@link #resolve(Job)}.
 */
protected void updateCache(@Nonnull Job<?,?> job, @Nullable Run<?,?> b) {
  final int n = b==null ? RESOLVES_TO_NONE : b.getNumber();
  File cache = getPermalinkFile(job);
  cache.getParentFile().mkdirs();
  try {
    String target = String.valueOf(n);
    if (b != null && !new File(job.getBuildDir(), target).exists()) {
      // (re)create the build Number->Id symlink
      Util.createSymlink(job.getBuildDir(),b.getId(),target,TaskListener.NULL);
    }
    writeSymlink(cache, target);
  } catch (IOException e) {
    LOGGER.log(Level.WARNING, "Failed to update "+job+" "+getId()+" permalink for " + b, e);
    cache.delete();
  } catch (InterruptedException e) {
    LOGGER.log(Level.WARNING, "Failed to update "+job+" "+getId()+" permalink for " + b, e);
    cache.delete();
  }
}

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

/**
 * Backward compatibility.
 *
 * We used to have $JENKINS_HOME/jobs/JOBNAME/lastStable and lastSuccessful symlinked to the appropriate
 * builds, but now those are done in {@link PeepholePermalink}. So here, we simply create symlinks that
 * resolves to the symlink created by {@link PeepholePermalink}.
 */
private void createSymlink(@Nonnull TaskListener listener, @Nonnull String name, @Nonnull PermalinkProjectAction.Permalink target) throws InterruptedException {
  File buildDir = getParent().getBuildDir();
  File rootDir = getParent().getRootDir();
  String targetDir;
  if (buildDir.equals(new File(rootDir, "builds"))) {
    targetDir = "builds" + File.separator + target.getId();
  } else {
    targetDir = buildDir + File.separator + target.getId();
  }
  Util.createSymlink(rootDir, targetDir, name, listener);
}

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

static void writeSymlink(File cache, String target) throws IOException, InterruptedException {
  LOGGER.log(Level.FINE, "writeSymlink {0} → {1}", new Object[] {cache, target});
  synchronized (symlinks) {
    symlinks.put(cache, target);
  }
  StringWriter w = new StringWriter();
  StreamTaskListener listener = new StreamTaskListener(w);
  Util.createSymlink(cache.getParentFile(),target,cache.getName(),listener);
  // Avoid calling resolveSymlink on a nonexistent file as it will probably throw an IOException:
  if (!exists(cache) || Util.resolveSymlink(cache)==null) {
   // symlink not supported. use a regular file
   AtomicFileWriter cw = new AtomicFileWriter(cache);
   try {
     cw.write(target);
     cw.commit();
   } finally {
     cw.abort();
   }
  }
}

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

public Void invoke(File f, VirtualChannel channel) throws IOException, InterruptedException {
    symlinking(f);
    Util.createSymlink(f.getParentFile(),target,f.getName(),listener);
    return null;
  }
});

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

System.err.println(build + " could not be renamed");
Util.createSymlink(builds, id, Integer.toString(number), StreamTaskListener.fromStderr());

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

/**
 * Remembers the value 'n' in the cache for future {@link #resolve(Job)}.
 */
protected void updateCache(@Nonnull Job<?,?> job, @Nullable Run<?,?> b) {
  final int n = b==null ? RESOLVES_TO_NONE : b.getNumber();
  File cache = getPermalinkFile(job);
  cache.getParentFile().mkdirs();
  try {
    String target = String.valueOf(n);
    if (b != null && !new File(job.getBuildDir(), target).exists()) {
      // (re)create the build Number->Id symlink
      Util.createSymlink(job.getBuildDir(),b.getId(),target,TaskListener.NULL);
    }
    writeSymlink(cache, target);
  } catch (IOException e) {
    LOGGER.log(Level.WARNING, "Failed to update "+job+" "+getId()+" permalink for " + b, e);
    cache.delete();
  } catch (InterruptedException e) {
    LOGGER.log(Level.WARNING, "Failed to update "+job+" "+getId()+" permalink for " + b, e);
    cache.delete();
  }
}

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

/**
 * Backward compatibility.
 *
 * We used to have $JENKINS_HOME/jobs/JOBNAME/lastStable and lastSuccessful symlinked to the appropriate
 * builds, but now those are done in {@link PeepholePermalink}. So here, we simply create symlinks that
 * resolves to the symlink created by {@link PeepholePermalink}.
 */
private void createSymlink(@Nonnull TaskListener listener, @Nonnull String name, @Nonnull PermalinkProjectAction.Permalink target) throws InterruptedException {
  File buildDir = getParent().getBuildDir();
  File rootDir = getParent().getRootDir();
  String targetDir;
  if (buildDir.equals(new File(rootDir, "builds"))) {
    targetDir = "builds" + File.separator + target.getId();
  } else {
    targetDir = buildDir + File.separator + target.getId();
  }
  Util.createSymlink(rootDir, targetDir, name, listener);
}

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

private void createSymlink(TaskListener listener, String name) throws InterruptedException {
  Util.createSymlink(getProject().getBuildDir(),"builds/"+getId(),"../"+name,listener);
}

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

private void createSymlink(TaskListener listener, String name) throws InterruptedException {
  Util.createSymlink(getProject().getBuildDir(), "builds/" + getId(), "../" + name, listener);
}

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

private void createSymlink(TaskListener listener, String name) throws InterruptedException {
  Util.createSymlink(getProject().getBuildDir(),"builds/"+getId(),"../"+name,listener);
}

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

private void createSymlink(TaskListener listener, String name) throws InterruptedException {
  Util.createSymlink(getProject().getBuildDir(),"builds/"+getId(),"../"+name,listener);
}

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

static void writeSymlink(File cache, String target) throws IOException, InterruptedException {
  LOGGER.log(Level.FINE, "writeSymlink {0} → {1}", new Object[] {cache, target});
  synchronized (symlinks) {
    symlinks.put(cache, target);
  }
  StringWriter w = new StringWriter();
  StreamTaskListener listener = new StreamTaskListener(w);
  Util.createSymlink(cache.getParentFile(),target,cache.getName(),listener);
  // Avoid calling resolveSymlink on a nonexistent file as it will probably throw an IOException:
  if (!exists(cache) || Util.resolveSymlink(cache)==null) {
   // symlink not supported. use a regular file
   AtomicFileWriter cw = new AtomicFileWriter(cache);
   try {
     cw.write(target);
     cw.commit();
   } finally {
     cw.abort();
   }
  }
}

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

Util.createSymlink(getRootDir(),
    "../../modules/" + moduleFsName + "/builds/" + newBuild.getId() /*ugly!*/,
    moduleFsName, StreamTaskListener.NULL);

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

Util.createSymlink(getRootDir(),
    "../../modules/" + moduleFsName + "/builds/" + newBuild.getId() /*ugly!*/,
    moduleFsName, StreamTaskListener.NULL);

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

Util.createSymlink(getRootDir(),
    "../../modules/" + moduleFsName + "/builds/" + newBuild.getId() /*ugly!*/,
    moduleFsName, StreamTaskListener.NULL);

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

Util.createSymlink(getRootDir(),
    "../../modules/"+ moduleFsName +"/builds/"+newBuild.getId() /*ugly!*/,
    moduleFsName, StreamTaskListener.NULL);

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

Util.createSymlink(getRootDir(),
    "../../modules/"+ moduleFsName +"/builds/"+newBuild.getId() /*ugly!*/,
    moduleFsName, StreamTaskListener.NULL);

相关文章

微信公众号

最新文章

更多