public File getBuildDirFor(Job job) { return expandVariablesForDirectory(buildsDir, job); }
private File expandVariablesForDirectory(String base, Item item) { return new File(expandVariablesForDirectory(base, item.getFullName(), item.getRootDir().getPath())); }
public FilePath getWorkspaceFor(TopLevelItem item) { for (WorkspaceLocator l : WorkspaceLocator.all()) { FilePath workspace = l.locate(item, this); if (workspace != null) { return workspace; } } return new FilePath(expandVariablesForDirectory(workspaceDir, item)); }
String replacedValue = expandVariablesForDirectory(newBuildsDirValue, "doCheckRawBuildsDir-Marker:foo", Jenkins.getInstance().getRootDir().getPath() + "/jobs/doCheckRawBuildsDir-Marker$foo");
@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); } } } }
public File getBuildDirFor(Job job) { return expandVariablesForDirectory(buildsDir, job); }
private File expandVariablesForDirectory(String base, Item item) { return new File(expandVariablesForDirectory(base, item.getFullName(), item.getRootDir().getPath())); }
public FormValidation doCheckRawBuildsDir(@QueryParameter String value) { String replacedValue = expandVariablesForDirectory(value, "doCheckRawBuildsDir-Marker:foo", Jenkins.getInstance().getRootDir().getPath() + "/jobs/doCheckRawBuildsDir-Marker$foo");
public FilePath getWorkspaceFor(TopLevelItem item) { for (WorkspaceLocator l : WorkspaceLocator.all()) { FilePath workspace = l.locate(item, this); if (workspace != null) { return workspace; } } return new FilePath(expandVariablesForDirectory(workspaceDir, item)); }
@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); } } } }