package org.jenkinsci.plugins.p4.changes; import java.io.BufferedOutputStream; import java.io.File; import java.io.FileNotFoundException; import java.io.FileOutputStream; import java.io.OutputStreamWriter; import java.io.PrintStream; import java.io.UnsupportedEncodingException; import java.net.URLEncoder; import java.nio.charset.Charset; import java.util.Collection; import java.util.Collections; import java.util.Iterator; import java.util.List; import org.apache.commons.lang.StringEscapeUtils; import org.kohsuke.stapler.framework.io.WriterOutputStream; import com.perforce.p4java.core.IFix; import com.perforce.p4java.core.file.FileAction; import com.perforce.p4java.core.file.IFileSpec; import hudson.model.Run; import hudson.scm.ChangeLogSet; import hudson.scm.RepositoryBrowser; public class P4ChangeSet extends ChangeLogSet<P4ChangeEntry> { private List<P4ChangeEntry> history; protected P4ChangeSet(Run<?, ?> run, RepositoryBrowser<?> browser, List<P4ChangeEntry> logs) { super(run, browser); this.history = Collections.unmodifiableList(logs); } public Iterator<P4ChangeEntry> iterator() { return history.iterator(); } @Override public boolean isEmptySet() { return history.isEmpty(); } public List<P4ChangeEntry> getHistory() { return history; } public Collection<P4ChangeEntry> getLogs() { return history; } public static void store(File file, List<P4ChangeEntry> changes) { try { FileOutputStream o = new FileOutputStream(file); BufferedOutputStream b = new BufferedOutputStream(o); Charset c = Charset.forName("UTF-8"); OutputStreamWriter w = new OutputStreamWriter(b, c); WriterOutputStream s = new WriterOutputStream(w); PrintStream stream = new PrintStream(s, true, "UTF-8"); stream.println("<?xml version='1.0' encoding='UTF-8'?>"); stream.println("<changelog>"); for (P4ChangeEntry cl : changes) { stream.println("\t<entry>"); stream.println("\t\t<changenumber><changeInfo>" + cl.getId() + "</changeInfo>"); stream.println("\t\t<clientId>" + cl.getClientId() + "</clientId>"); stream.println("\t\t<msg>" + StringEscapeUtils.escapeXml(cl.getMsg()) + "</msg>"); stream.println("\t\t<changeUser>" + StringEscapeUtils.escapeXml(cl.getAuthor().getDisplayName()) + "</changeUser>"); stream.println("\t\t<changeTime>" + StringEscapeUtils.escapeXml(cl.getChangeTime()) + "</changeTime>"); stream.println("\t\t<shelved>" + cl.isShelved() + "</shelved>"); stream.println("\t\t<files>"); List<IFileSpec> files = cl.getFiles(); if (files != null) { for (IFileSpec filespec : files) { FileAction action = filespec.getAction(); int revision = filespec.getEndRevision(); // URL encode depot path String depotPath = filespec.getDepotPathString(); String safePath = URLEncoder.encode(depotPath, "UTF-8"); stream.println("\t\t<file endRevision=\"" + revision + "\" action=\"" + action.name() + "\" depot=\"" + safePath + "\" />"); } } stream.println("\t\t</files>"); stream.println("\t\t<jobs>"); List<IFix> jobs = cl.getJobs(); if (jobs != null) { for (IFix job : jobs) { String id = job.getJobId(); String status = job.getStatus(); stream.println("\t\t<job id=\"" + id + "\" status=\"" + status + "\" />"); } } stream.println("\t\t</jobs>"); stream.println("\t\t</changenumber>"); stream.println("\t</entry>"); } stream.println("</changelog>"); stream.close(); } catch (FileNotFoundException e) { e.printStackTrace(); } catch (UnsupportedEncodingException e) { e.printStackTrace(); } } }
# | Change | User | Description | Committed | |
---|---|---|---|---|---|
#3 | 22326 | Paul Allen | Merging down using p4-jenkins | ||
#2 | 21990 | Paul Allen |
Reporting Graph changes. Update Browser and Jelly code to use String and not URL for url in Data Binding to Jelly. Use P4AffectedFile object for XML storage and not IFileSpec to allow Graph use. |
||
#1 | 21940 | Paul Allen | Branching using p4-jenkins | ||
//guest/perforce_software/p4jenkins/main/src/main/java/org/jenkinsci/plugins/p4/changes/P4ChangeSet.java | |||||
#9 | 19712 | Paul Allen | NPE fix when code line has no changes. | ||
#8 | 19581 | Paul Allen | Minor fixes to satisfy FindBugs Analysis. | ||
#7 | 19303 | Paul Allen |
Protect against null when no jobs are in a changelist. JENKINS-33993 |
||
#6 | 16409 | Paul Allen |
Use Fix records for Job information. 'p4 fixes' is lighter and still provides enough useful data. Includes jelly fix and extra job data in changelog.xml. |
||
#5 | 15750 | Paul Allen |
Use a P4Revision object and not int/String as Object. In sure that there is no ambiguity with the revision specifier. Should fix change summary when using the Workflow plugin. JENKINS-30425 |
||
#4 | 14150 | Paul Allen |
URL Encode/Decode the depot path for changes. Filenames with ampersands was causing Jelly to break when showing the change detail. JENKINS-29017 |
||
#3 | 11626 | Paul Allen |
Workflow support. - Updated the plugin to the latest LTS Jenkins release 1.580.3. - Updated P4Java to 2014.1 Tested with simple ‘static’ workspace, there may be limitations with ‘manual’ workspace. Plan to add DSL support by extending the SCMStep class. #review-11537 JENKINS-24206 |
||
#2 | 11084 | Paul Allen |
(mjoubert) Fully populate changelog.xml Replaces sparse change log which only recorded the change number. The change is now recorded in full allowing faster page load times. The number of files listed in the change is limited to 50; to view larger changes please add a repo browser such as Swarm, Fisheye, P4Web, etc… |
||
#1 | 9690 | Paul Allen |
[Branching using p4-jenkins] Release 1.0.1 |
||
//guest/paul_allen/dev/p4-jenkins/p4-client/src/main/java/org/jenkinsci/plugins/p4/changes/P4ChangeSet.java | |||||
#1 | 9672 | Paul Allen | Refactor name from 'p4_client' to 'p4'. | ||
//guest/paul_allen/dev/p4-jenkins/p4-client/src/main/java/org/jenkinsci/plugins/p4_client/changes/P4ChangeSet.java | |||||
#2 | 9055 | Paul Allen |
Label support. Build at a label using the pram 'label'. This includes adding the label to the ChangeEntry, building the change reports and Browser links to Swarm. (TPI-102) |
||
#1 | 8915 | Paul Allen |
Support for ChangeLog and RepoBrowser. - Added RepoBrowser for Swarm (porting the others should be easy) - ChangeLog XML file now only stores the changelist number all other information is fetched from Perforce |