@Override public FilePath getBaseDirectory(final AbstractBuild<?, ?> build) { return new FilePath(Hudson.getInstance().getRootPath(), build.getArtifactsDir().getAbsolutePath()); }
/** * Copied from {@link hudson.tasks.ArtifactArchiver}. */ private void deleteOldBuildArtifacts() { AbstractBuild<?, ?> b = build.getProject().getLastCompletedBuild(); Result bestResultSoFar = Result.NOT_BUILT; while (b != null) { if (b.getResult().isBetterThan(bestResultSoFar)) { bestResultSoFar = b.getResult(); } else { // remove old artifacts File ad = b.getArtifactsDir(); if (ad.exists()) { muxlog.info("Deleting old Maven artifacts from {}", b.getDisplayName()); try { Util.deleteRecursive(ad); } catch (IOException e) { muxlog.error("Failed to delete old Maven artifacts", e); } } } b = b.getPreviousBuild(); } } }
@Override public boolean prebuild(AbstractBuild<?, ?> build, BuildListener listener) { if(latestOnly) { AbstractBuild<?,?> b = build.getProject().getLastCompletedBuild(); Result bestResultSoFar = Result.NOT_BUILT; while(b!=null) { if (b.getResult().isBetterThan(bestResultSoFar)) { bestResultSoFar = b.getResult(); } else { // remove old artifacts File ad = b.getArtifactsDir(); if(ad.exists()) { listener.getLogger().println(Messages.ArtifactArchiver_DeletingOld(b.getDisplayName())); try { Util.deleteRecursive(ad); } catch (IOException e) { e.printStackTrace(listener.error(e.getMessage())); } } } b = b.getPreviousBuild(); } } return true; }
@Override public boolean prebuild(AbstractBuild<?, ?> build, BuildListener listener) { if (latestOnly) { AbstractBuild<?, ?> b = build.getProject().getLastCompletedBuild(); Result bestResultSoFar = Result.NOT_BUILT; while (b != null) { if (b.getResult().isBetterThan(bestResultSoFar)) { bestResultSoFar = b.getResult(); } else { // remove old artifacts File ad = b.getArtifactsDir(); if (ad.exists()) { listener.getLogger().println(Messages.ArtifactArchiver_DeletingOld(b.getDisplayName())); try { Util.deleteRecursive(ad); } catch (IOException e) { e.printStackTrace(listener.error(e.getMessage())); } } } b = b.getPreviousBuild(); } } return true; }
@Override public boolean prebuild(AbstractBuild<?, ?> build, BuildListener listener) { if(latestOnly) { AbstractBuild<?,?> b = build.getProject().getLastCompletedBuild(); Result bestResultSoFar = Result.NOT_BUILT; while(b!=null) { if (b.getResult().isBetterThan(bestResultSoFar)) { bestResultSoFar = b.getResult(); } else { // remove old artifacts File ad = b.getArtifactsDir(); if(ad.exists()) { listener.getLogger().println(Messages.ArtifactArchiver_DeletingOld(b.getDisplayName())); try { Util.deleteRecursive(ad); } catch (IOException e) { e.printStackTrace(listener.error(e.getMessage())); } } } b = b.getPreviousBuild(); } } return true; }
@Override public boolean prebuild(AbstractBuild<?, ?> build, BuildListener listener) { if(latestOnly) { AbstractBuild<?,?> b = build.getProject().getLastCompletedBuild(); Result bestResultSoFar = Result.NOT_BUILT; while(b!=null) { if (b.getResult().isBetterThan(bestResultSoFar)) { bestResultSoFar = b.getResult(); } else { // remove old artifacts File ad = b.getArtifactsDir(); if(ad.exists()) { listener.getLogger().println(Messages.ArtifactArchiver_DeletingOld(b.getDisplayName())); try { Util.deleteRecursive(ad); } catch (IOException e) { e.printStackTrace(listener.error(e.getMessage())); } } } b = b.getPreviousBuild(); } } return true; }
@SuppressWarnings("rawtypes") private void archiveArtifacts(AbstractBuild build, Runner runner, String latestVersion) throws IOException, InterruptedException { FilePath path = build.getWorkspace().child(pathToDebian).child(".."); String mask = "*" + latestVersion + "*.deb"; for (FilePath file:path.list(mask)) { runner.announce("Archiving file <{0}> as a build artifact", file.getName()); } path.copyRecursiveTo(mask, new FilePath(build.getArtifactsDir())); }
@Override public boolean perform(final AbstractBuild<?, ?> build, final Launcher launcher, final BuildListener listener) throws InterruptedException, IOException { final PrintStream console = listener.getLogger(); if (!isBuildGoodEnoughToRun(build, console)) return true; final BPBuildEnv currentBuildEnv = new BPBuildEnv(getEnvironmentVariables(build, listener), build.getWorkspace(), build.getTimestamp()); BPBuildEnv targetBuildEnv = null; if (PROMOTION_CLASS_NAME.equals(build.getClass().getCanonicalName())) { AbstractBuild<?, ?> promoted; try { final Method getTarget = build.getClass().getMethod("getTarget", (Class<?>[]) null); promoted = (AbstractBuild) getTarget.invoke(build, (Object[]) null); } catch (Exception e) { throw new RuntimeException(Messages.exception_failedToGetPromotedBuild(), e); } targetBuildEnv = new BPBuildEnv(getEnvironmentVariables(promoted, listener), new FilePath(promoted.getArtifactsDir()), promoted.getTimestamp()); } final BPBuildInfo buildInfo = new BPBuildInfo(listener, consolePrefix, Hudson.getInstance().getRootPath(), currentBuildEnv, targetBuildEnv); fixup(build, buildInfo); final Result result = delegate.perform(buildInfo); if (build.getResult() == null) build.setResult(result); else build.setResult(result.combine(build.getResult())); return result.isBetterOrEqualTo(Result.UNSTABLE); }
FilePath archiveDirectory = new FilePath(build.getArtifactsDir()); archiveDirectory.mkdirs(); log.debug("Archiving to {}", archiveDirectory);
File dir = build.getArtifactsDir(); dir.mkdirs();
File dir = build.getArtifactsDir(); dir.mkdirs();
File dir = build.getArtifactsDir(); dir.mkdirs();
File dir = build.getArtifactsDir(); dir.mkdirs();
new FilePath(build.getArtifactsDir()), new FilePath(build.getProject().getRootDir()), new FilePath(build.getRootDir()),