package org.jenkinsci.plugins.p4.client; import hudson.model.AutoCompletionCandidates; import java.util.List; import com.perforce.p4java.core.IDepot; import com.perforce.p4java.core.file.FileSpecBuilder; import com.perforce.p4java.core.file.IFileSpec; import com.perforce.p4java.option.server.GetDepotFilesOptions; import com.perforce.p4java.option.server.GetDirectoriesOptions; import com.perforce.p4java.server.IOptionsServer; public class NavigateHelper { public static AutoCompletionCandidates getPath(String value) { if (!value.startsWith("//")) { return null; } // remove leading '//' markers for depot matching String depot = value.substring(2); if (!depot.contains("/")) { return listDepots(depot); } AutoCompletionCandidates c = new AutoCompletionCandidates(); listDirs(value, c); listFiles(value, c); return c; } private static AutoCompletionCandidates listDepots(String value) { AutoCompletionCandidates c = new AutoCompletionCandidates(); try { IOptionsServer iserver = ConnectionFactory.getConnection(); if (iserver != null) { List<IDepot> list = iserver.getDepots(); for (IDepot l : list) { if (l.getName().startsWith(value)) { c.add("//" + l.getName()); } } } } catch (Exception e) { } return c; } private static void listDirs(String value, AutoCompletionCandidates c) { try { IOptionsServer iserver = ConnectionFactory.getConnection(); if (iserver != null && value.length() > 4) { List<IFileSpec> dirs; dirs = FileSpecBuilder.makeFileSpecList(value + "*"); GetDirectoriesOptions opts = new GetDirectoriesOptions(); List<IFileSpec> list = iserver.getDirectories(dirs, opts); if (list == null) { return; } if (list.size() > 10) { list = list.subList(0, 10); } for (IFileSpec l : list) { String dir = l.getOriginalPathString(); if (dir != null) { c.add(dir); } } } } catch (Exception e) { } } private static void listFiles(String value, AutoCompletionCandidates c) { try { IOptionsServer iserver = ConnectionFactory.getConnection(); if (iserver != null && value.length() > 4) { List<IFileSpec> files; files = FileSpecBuilder.makeFileSpecList(value + "..."); GetDepotFilesOptions opts = new GetDepotFilesOptions(); opts.setMaxResults(10); List<IFileSpec> list = iserver.getDepotFiles(files, opts); for (IFileSpec l : list) { c.add(l.getDepotPathString()); } } } catch (Exception e) { } } }
# | Change | User | Description | Committed | |
---|---|---|---|---|---|
#6 | 28508 | Paul Allen |
Cache P4TICKET in session. Session cache now keyed on Credential ID and stores: User, Expiry time and Ticket. |
||
#5 | 28464 | Paul Allen |
Formalise user session cache. Added Jelly options to Global Configuration. User cache is disabled by default. Ticket Minimum life is set to 30 minutes. JENKINS-60141 |
||
#4 | 28460 | Paul Allen |
Session cache to track ticket time. Initial design to reduce 'p4 login -s' calls with user session cache to track ticket time. |
||
#3 | 23373 | Paul Allen |
Lightweight checkout support. Implementation for scm-api classes SCMFile and SCMFileSystem, allowing Jenkins to navigate Perforce within the scope of a workspace view. Lightweight checkout uses a tempoary Perforce workspace to naviagete and fetch the files. The client name and client view mapping will be modified from a template name e.g. jenkins-${NODE_NAME}-${JOB_NAME} to the tempoary name jenkinsTemp-UUID. Alternativly if a user as used ${P4_CLIENT} in the client mapping this will remain unchanged and will be get expanded during the job run. JENKINS-45999 JENKINS-46269 |
||
#2 | 23263 | Paul Allen | Update NavigateHelper for future use. | ||
#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/client/NavigateHelper.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/client/NavigateHelper.java | |||||
#1 | 9133 | Paul Allen |
Added Workspace mode for versioned Client Specs. Client Spec can be specified by depot path and used to configure workspace for build. - Includes fix for removing header when using p4 print. |