hudson.model.Job.getBuildDir()方法的使用及代码示例

x33g5p2x  于2022-01-21 转载在 其他  
字(8.2k)|赞(0)|评价(0)|浏览(119)

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

Job.getBuildDir介绍

[英]Directory for storing Run records.

Some Jobs may not have backing data store for Runs, but those Jobs that use file system for storing data should use this directory for consistency. This dir could be configured by setting HUDSON_BUILDS property in JNDI or Environment or System properties.
[中]用于存储运行记录的目录。
某些作业可能没有用于运行的备份数据存储,但使用文件系统存储数据的作业应使用此目录以保持一致性。可以通过在JNDI或环境或系统属性中设置HUDSON_BUILDS属性来配置此目录。

代码示例

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

/**
 * Get the root directory of this {@link Run} on the master.
 * Files related to this {@link Run} should be stored below this directory.
 * @return Root directory of this {@link Run} on the master. Never null
 */
@Override
public @Nonnull File getRootDir() {
  return new File(project.getBuildDir(), Integer.toString(number));
}

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

/**
 * The file in which the permalink target gets recorded.
 */
protected File getPermalinkFile(Job<?,?> job) {
  return new File(job.getBuildDir(),getId());
}

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

@Override
public void movedTo(DirectlyModifiableTopLevelItemGroup destination, AbstractItem newItem, File destDir) throws IOException {
  Job newJob = (Job) newItem; // Missing covariant parameters type here.
  File oldBuildDir = getBuildDir();
  super.movedTo(destination, newItem, destDir);
  File newBuildDir = getBuildDir();
  if (oldBuildDir.isDirectory()) {
    FileUtils.moveDirectory(oldBuildDir, newBuildDir);
  }
}

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

/**
 * Renames a job.
 */
@Override
public void renameTo(String newName) throws IOException {
  File oldBuildDir = getBuildDir();
  super.renameTo(newName);
  File newBuildDir = getBuildDir();
  if (oldBuildDir.isDirectory() && !newBuildDir.isDirectory()) {
    if (!newBuildDir.getParentFile().isDirectory()) {
      newBuildDir.getParentFile().mkdirs();
    }
    if (!oldBuildDir.renameTo(newBuildDir)) {
      throw new IOException("failed to rename " + oldBuildDir + " to " + newBuildDir);
    }
  }
}

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

/**
 * Backward compatibility method that notifies {@link RunMap} of who the owner is.
 *
 * Traditionally, this method blocked and loaded all the build records on the disk,
 * but now all the actual loading happens lazily.
 *
 * @param job
 *      Job that owns this map.
 * @param cons
 *      Used to create new instance of {@link Run}.
 * @deprecated as of 1.485
 *      Use {@link #RunMap(File, Constructor)}
 */
@Deprecated
public void load(Job job, Constructor<R> cons) {
  this.cons = cons;
  initBaseDir(job.getBuildDir());
}

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

@Override public void onLocationChanged(Item item, String oldFullName, String newFullName) {
    if (item instanceof LazyLoadingJob) {
      RunMap<?> builds = ((LazyLoadingJob) item).getLazyBuildMixIn().builds;
      builds.updateBaseDir(((Job) item).getBuildDir());
    }
  }
}

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

@Override public void delete() throws IOException, InterruptedException {
  super.delete();
  Util.deleteRecursive(getBuildDir());
}

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

File rootDir = getRootDir();
if (!rootDir.isDirectory()) {
  throw new IOException(this + ": " + rootDir + " looks to have already been deleted; siblings: " + Arrays.toString(project.getBuildDir().list()));

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

private RunMap<RunT> createBuildRunMap() {
  RunMap<RunT> r = new RunMap<RunT>(asJob().getBuildDir(), new RunMap.Constructor<RunT>() {
    @Override public RunT create(File dir) throws IOException {
      return loadBuild(dir);
    }
  });
  RunIdMigrator runIdMigrator = asJob().runIdMigrator;
  assert runIdMigrator != null;
  r.runIdMigrator = runIdMigrator;
  return r;
}

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

@Override public void onCreatedFromScratch() {
  super.onCreatedFromScratch();
  runIdMigrator = new RunIdMigrator();
  runIdMigrator.created(getBuildDir());
}

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

@Override
  public void onLocationChanged(Item item, String oldFullName, String newFullName) {
    final Jenkins jenkins = Jenkins.getInstance();
    if (!jenkins.isDefaultBuildDir() && item instanceof Job) {
      File newBuildDir = ((Job)item).getBuildDir();
      try {
        if (!Util.isDescendant(item.getRootDir(), newBuildDir)) {
          //OK builds are stored somewhere outside of the item's root, so none of the other move operations has probably moved it.
          //So let's try even though we lack some information
          String oldBuildsDir = Jenkins.expandVariablesForDirectory(jenkins.getRawBuildsDir(), oldFullName, "<NOPE>");
          if (oldBuildsDir.contains("<NOPE>")) {
            LOGGER.severe(String.format("Builds directory for job %1$s appears to be outside of item root," +
                " but somehow still containing the item root path, which is unknown. Cannot move builds from %2$s to %1$s.", newFullName, oldFullName));
          } else {
            File oldDir = new File(oldBuildsDir);
            if (oldDir.isDirectory()) {
              try {
                FileUtils.moveDirectory(oldDir, newBuildDir);
              } catch (IOException e) {
                LOGGER.log(Level.SEVERE, String.format("Failed to move %s to %s", oldBuildsDir, newBuildDir.getAbsolutePath()), e);
              }
            }
          }
        }
      } catch (IOException e) {
        LOGGER.log(Level.WARNING, "Failed to inspect " + item.getRootDir() + ". Builds might not be moved.", e);
      }
    }
  }
}

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

super.onLoad(parent, name);
File buildDir = getBuildDir();
runIdMigrator = new RunIdMigrator();
runIdMigrator.migrate(buildDir, Jenkins.getInstance().getRootDir());

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

/**
 * Get the root directory of this {@link Run} on the master.
 * Files related to this {@link Run} should be stored below this directory.
 * @return Root directory of this {@link Run} on the master. Never null
 */
@Override
public @Nonnull File getRootDir() {
  return new File(project.getBuildDir(), Integer.toString(number));
}

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

protected XmlFile getConfigXml(Job<?, ?> project) throws IOException {
    try {
      String escapedRepoName = URLEncoder.encode(reponame, "UTF8");
      File file = new File(project.getBuildDir() + "/pullrequests", escapedRepoName);
      return Items.getConfigFile(file);
    } catch (UnsupportedEncodingException e) {
      throw new IOException(e);
    }
  }
}

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

/**
 * Root directory of this {@link Run} on the master.
 *
 * Files related to this {@link Run} should be stored below this directory.
 */
public File getRootDir() {
  File f = new File(project.getBuildDir(),getId());
  f.mkdirs();
  return f;
}

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

/*package*/ TextFile getNextBuildNumberFile() {
  File buildsDir = getBuildDir();
  if (!buildsDir.exists()) {
    buildsDir.mkdirs();
  }
  return new TextFile(new File(buildsDir, "../nextBuildNumber"));
}

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

public FormValidation doCheck(@AncestorInPath Job<?, ?> project, @QueryParameter String value) throws IOException {
    FilePath buildDirectory = new FilePath(project.getBuildDir());
    return FilePath.validateFileMask(buildDirectory, value);
  }
}

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

@Override public void onCreatedFromScratch() {
  super.onCreatedFromScratch();
  runIdMigrator = new RunIdMigrator();
  runIdMigrator.created(getBuildDir());
}

相关文章

微信公众号

最新文章

更多

Job类方法