/** Builds up an HTML fragment that starts all the download jobs. */ public String generateFragment() { if (neverUpdate) return ""; StringBuilder buf = new StringBuilder(); if (Hudson.getInstance().hasPermission(Hudson.READ)) { long now = System.currentTimeMillis(); for (Downloadable d : Downloadable.all()) { if (d.getDue() < now) { buf.append("<script>downloadService.download(") .append(QuotedStringTokenizer.quote(d.getId())) .append(',') .append(QuotedStringTokenizer.quote(d.getUrl())) .append(',') .append("{version:" + QuotedStringTokenizer.quote(Hudson.VERSION) + '}') .append(',') .append( QuotedStringTokenizer.quote( Stapler.getCurrentRequest().getContextPath() + '/' + getUrl() + "/byId/" + d.getId() + "/postBack")) .append(',') .append("null);</script>"); } } } return buf.toString(); }
@Override protected int act(List<AbstractBuild<?, ?>> builds) throws IOException { // Loading job for this CLI command requires Item.READ permission. // No other permission check needed. switch (format) { case XML: PrintWriter w = new PrintWriter(stdout); w.println("<changes>"); for (AbstractBuild build : builds) { w.println("<build number='" + build.getNumber() + "'>"); ChangeLogSet<?> cs = build.getChangeSet(); Model p = new ModelBuilder().get(cs.getClass()); p.writeTo(cs, Flavor.XML.createDataWriter(cs, w)); w.println("</build>"); } w.println("</changes>"); w.flush(); break; case CSV: for (AbstractBuild build : builds) { ChangeLogSet<?> cs = build.getChangeSet(); for (Entry e : cs) { stdout.printf( "%s,%s%n", QuotedStringTokenizer.quote(e.getAuthor().getId()), QuotedStringTokenizer.quote(e.getMsg())); } } break; case PLAIN: for (AbstractBuild build : builds) { ChangeLogSet<?> cs = build.getChangeSet(); for (Entry e : cs) { stdout.printf("%s\t%s%n", e.getAuthor(), e.getMsg()); for (String p : e.getAffectedPaths()) stdout.println(" " + p); } } break; } return 0; }
public static String escape(String name) { if (needsEscape(name)) return QuotedStringTokenizer.quote(name); return name; }