package org.jenkinsci.plugins.p4.changes; import hudson.model.User; import hudson.scm.ChangeLogSet; import java.text.ParseException; import java.text.SimpleDateFormat; import java.util.ArrayList; import java.util.Collection; import java.util.Date; import java.util.List; import java.util.Map; import javax.print.attribute.standard.DateTimeAtCompleted; import org.jenkinsci.plugins.p4.client.ConnectionHelper; import org.kohsuke.stapler.export.Exported; import org.kohsuke.stapler.export.ExportedBean; import com.perforce.p4java.core.ChangelistStatus; import com.perforce.p4java.core.IJob; import com.perforce.p4java.core.file.FileAction; import com.perforce.p4java.core.file.IFileSpec; import com.perforce.p4java.impl.generic.core.Changelist; import com.perforce.p4java.impl.generic.core.Label; public class P4ChangeEntry extends ChangeLogSet.Entry { private int FILE_COUNT_LIMIT = 50; private Object id; private User author; private Date date = new Date(); private String clientId = ""; private String msg = ""; private Collection<String> affectedPaths; private boolean shelved; private boolean label; private boolean fileLimit = false; public List<IFileSpec> files; private List<IJob> jobs; public P4ChangeEntry(P4ChangeSet parent) { super(); setParent(parent); files = new ArrayList<IFileSpec>(); jobs = new ArrayList<IJob>(); affectedPaths = new ArrayList<String>(); } public P4ChangeEntry() { } public void setChange(ConnectionHelper p4, int changeId) throws Exception { Changelist changelist = (Changelist) p4.getChange(changeId); // set id id = changelist.getId(); // set author String user = changelist.getUsername(); author = User.get(user); // set date of change date = changelist.getDate(); // set client id clientId = changelist.getClientId(); // set display message msg = changelist.getDescription(); // set list of file revisions in change if (changelist.getStatus() == ChangelistStatus.PENDING) { files = p4.getShelvedFiles(changeId); shelved = true; } else { files = p4.getChangeFiles(changeId); shelved = false; } if (files.size() > FILE_COUNT_LIMIT) { fileLimit = true; files = files.subList(0, FILE_COUNT_LIMIT); } // set list of affected paths affectedPaths = new ArrayList<String>(); for (IFileSpec item : files) { affectedPaths.add(item.getDepotPathString()); } // set list of jobs in change this.jobs = changelist.getJobs(); } public void setLabel(ConnectionHelper p4, String labelId) throws Exception { label = true; Label label = (Label) p4.getLabel(labelId); // set id id = labelId; // set author String user = label.getOwnerName(); author = User.get(user); // set date of change date = label.getLastAccess(); // set client id clientId = labelId; // set display message msg = label.getDescription(); // set list of file revisions in change files = p4.getLabelFiles(labelId, FILE_COUNT_LIMIT + 1); if (files.size() > FILE_COUNT_LIMIT) { fileLimit = true; files = files.subList(0, FILE_COUNT_LIMIT); } // set list of affected paths affectedPaths = new ArrayList<String>(); for (IFileSpec item : files) { affectedPaths.add(item.getDepotPathString()); } } @Exported public Object getChangeNumber() { return id; } @Exported public String getChangeTime() { SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss"); return sdf.format(date); } public Object getId() { return id; } public void setId(Object value) { id = value; } @Override public User getAuthor() { return author; } public void setAuthor(String value) { author = User.get(value); } public Date getDate() { return date; } public void setDate(String value) { SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss"); try { date = sdf.parse(value); } catch (ParseException e) { // TODO Auto-generated catch block e.printStackTrace(); } } public void setClientId(String value) { clientId = value; } public String getClientId() { return clientId; } @Override public String getMsg() { return msg; } public void setMsg(String value) { msg = value; } @Override public Collection<String> getAffectedPaths() { return affectedPaths; } public boolean isFileLimit() { return fileLimit; } public List<IFileSpec> getFiles() { return files; } public String getAction(IFileSpec file) { FileAction action = file.getAction(); String s = action.name(); return s.replace("/", "_"); } public void setShelved(boolean value) { shelved = value; } public boolean isShelved() { return shelved; } public boolean isLabel() { return label; } public List<IJob> getJobs() { return jobs; } public String getJobStatus(IJob job) { Map<String, Object> map = job.getRawFields(); String status = (String) map.get("Status"); return status; } public String getJobSummary(IJob job) { String summary = job.getDescription(); if (summary.length() > 80) { summary = summary.substring(0, 80) + "..."; } return summary; } public int getMaxLimit() { return FILE_COUNT_LIMIT; } }
# | Change | User | Description | Committed | |
---|---|---|---|---|---|
#1 | 12955 | Sven Erik Knop | Branching using sknop.p4jenkins-main | ||
//guest/perforce_software/p4jenkins/main/src/main/java/org/jenkinsci/plugins/p4/changes/P4ChangeEntry.java | |||||
#9 | 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… |
||
#8 | 10939 | Paul Allen |
Tidy up changes. - Moved duration timings to ClientHelper and measure each task individually. - White space/formatting on P4ChangeEntry. - Temporarily backed-out p4-plugin.properties file (could damage builds - need to understand requirements) |
||
#7 | 10936 | Paul Allen |
(mjoubert) Pull request Add simple REST tags to match other plugin |
||
#6 | 10757 | Paul Allen |
More efficient listing of files. Listing files for the Change reporting used `p4 files //…@=<id>`, this now uses `p4 describe -s <id>` for changes and `p4 files //…@<id>` for labels. The `\\…@label` should be much more efficient as it only looks as the db.label table not db.rev. I can’t limit the scope to a workspace. Often the client name uses ${var}, which are not present at this point in the code. JENKINS-25303 |
||
#5 | 10668 | Matt Attaway | Adding a file to redirect JSAPI users to the new examples location | ||
#4 | 10201 | Paul Allen | Fix page loading error with no connection to P4 | ||
#3 | 9803 | Paul Allen | Merging using p4-jenkins | ||
#2 | 9769 | Paul Allen | Copying using p4-jenkins | ||
#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/P4ChangeEntry.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/P4ChangeEntry.java | |||||
#5 | 9127 | Paul Allen |
Added Browser support for P4Web. - Includes fix for move/add and move/delete icons when browsing change lists. |
||
#4 | 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) |
||
#3 | 8940 | Paul Allen |
Major refactor for the ConnectionHelper class to simplify serialisation. Fixed remote Jenkins JNLP slave connection issue. ClientHelper now extends ConnectionHelper and takes on all methods that require a client workspace. P4StandardCredentials is sent to the remote node instead of Credentials ID due to an issue accessing the Credentials store over a remote connection. For simplicity Client ID (workspace name) is serialised instead of the Workspace object. |
||
#2 | 8916 | Paul Allen | Unit tests for ChangeLog feature and minor fix when listing files if the change is Submitted or Shelved. | ||
#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 |