package org.jenkinsci.plugins.p4.workspace; import com.perforce.p4java.client.IClient; import com.perforce.p4java.server.IOptionsServer; import hudson.DescriptorExtensionList; import hudson.ExtensionPoint; import hudson.model.Describable; import jenkins.model.Jenkins; import org.kohsuke.stapler.DataBoundSetter; import java.io.Serializable; import java.util.HashMap; import java.util.Map; public abstract class Workspace implements Cloneable, ExtensionPoint, Describable<Workspace>, Serializable { private static final long serialVersionUID = 1L; private String charset; private boolean pinHost; private String rootPath; private String hostname; private Expand expand; private String syncID; public Workspace(String charset, boolean pinHost) { this.charset = charset; this.pinHost = pinHost; } public abstract WorkspaceType getType(); /** * Returns the client workspace name as defined in the configuration. This * may include ${tag} that have not been expanded. * * @return Client name */ public abstract String getName(); public abstract void setName(String name); public String getCharset() { return charset; } public boolean isPinHost() { return pinHost; } /** * Setup/Create a Perforce workspace for this mode. * * @param connection Server connection * @param user Perforce user * @return Perforce client * @throws Exception push up stack */ public abstract IClient setClient(IOptionsServer connection, String user) throws Exception; public WorkspaceDescriptor getDescriptor() { Jenkins j = Jenkins.getInstance(); if (j != null) { return (WorkspaceDescriptor) j.getDescriptor(getClass()); } return null; } public static DescriptorExtensionList<Workspace, WorkspaceDescriptor> all() { Jenkins j = Jenkins.getInstance(); if (j != null) { return j.<Workspace, WorkspaceDescriptor>getDescriptorList(Workspace.class); } return null; } public String getRootPath() { return rootPath; } public void setHostName(String hostname) { this.hostname = hostname; } public String getHostName() { return hostname; } public void setRootPath(String rootPath) { this.rootPath = rootPath; } public void setExpand(Map<String, String> map) { expand = new Expand(map); } public Expand getExpand() { // provide an empty map if Environment is not set. if(expand == null) { setExpand(new HashMap<String, String>()); } return expand; } public void addEnv(String tag, String value) { expand.set(tag, value); } /** * Returns the fully expanded client workspace name. * * @return Client name */ public String getFullName() { if (expand == null) { return getName(); } // expands Workspace name if formatters are used. String clientName = expand.format(getName(), false); // replace restricted characters with "-" as per the old plugin clientName = expand.clean(clientName); // store full name in expand options for use in view expand.set("P4_CLIENT", clientName); return clientName; } public String getSyncID() { String id = null; if (expand == null) { return id; } // if syncID provide expand or use client name. if (syncID != null && !syncID.isEmpty()) { id = expand.formatID(syncID); } else { id = expand.formatID(getName()); } // replace restricted characters with "-" as per the old plugin id = expand.clean(id); // remove .cloneNN during concurrent builds id = id.replaceAll(".clone\\d+$", ""); return id; } @DataBoundSetter public void setSyncID(String syncID) { this.syncID = syncID; } public Object clone() { try { return super.clone(); } catch (CloneNotSupportedException e) { return null; } } }
# | Change | User | Description | Committed | |
---|---|---|---|---|---|
#4 | 23689 | Paul Allen | Cleanup P4Task: Combined Workspace setup | ||
#3 | 23688 | Paul Allen | Cleanup P4Task: Pass workspace to ClientHelper | ||
#2 | 23685 | Paul Allen | Copy main -> dev | ||
#1 | 20641 | Paul Allen | Copy main -> dev (jenkinsci/p4-plugin) | ||
//guest/perforce_software/p4jenkins/main/src/main/java/org/jenkinsci/plugins/p4/workspace/Workspace.java | |||||
#13 | 20308 | Paul Allen |
P4Groovy (experimental) Get a P4 object in groovy. Supporting basic functions: ’run’ (to run perforce commands), ‘fetch’ and ‘save’ (to access Perforce specs). |
||
#12 | 20179 | Paul Allen | Javadoc fixes for java 8 builds. | ||
#11 | 19593 | Paul Allen | More minor fixes to satisfy FindBugs Analysis. | ||
#10 | 16770 | Paul Allen |
Enable ${P4_CLIENT} in client view mapping. Store full client name in expand options for use in view. JENKINS-32282 |
||
#9 | 13681 | Paul Allen |
Abstracted Expand class from Workspace. Added support for Label variable expansion in the name and description. |
||
#8 | 12888 | Paul Allen |
Merged Pull#11 @rpocase [JENKINS-28213] Force syncing a workspace that does not exist on the filesystem causes a FileNotFoundException. - Tidy up imports and white space |
||
#7 | 11472 | Paul Allen |
Pin the Workspace to the build host. Added a check box under the Workspace configuration to allow Jenkins to Pin the workspace, by setting the Host field. The hostname is resolved from the Computer object or InetAddress. |
||
#6 | 10906 | Paul Allen |
Matrix Polling and Parent control - Polling for Matrix builds calculates changes based on children. - Parent build disabled when using "Matrix options for Perforce" in the Matrix Configuration (can be enabled by checking the “Build parent” box). - Parent Build now substitutes ${var} with ‘*’ for the workspace view. e.g. //depot/${os}/… //ws/${os}/… becomes… //depot/*/… //ws/*/… instead of… //depot/os/… //ws/os/… |
||
#5 | 10755 | Paul Allen |
Separate name space for 'label' parameter. Perforce Review endpoint added `label`, `change`, `status`, `pass`, and `fail` parameter into the environment, which is a shared name space. This clashed with the default `label` matrix name and causing users issues. The change prefixes the review parameters with `p4.` on addition to the environment. |
||
#4 | 9803 | Paul Allen | Merging using p4-jenkins | ||
#3 | 9769 | Paul Allen | Copying using p4-jenkins | ||
#2 | 9738 | Paul Allen | Merging 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/workspace/Workspace.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/workspace/Workspace.java | |||||
#7 | 9495 | Paul Allen |
Fix Polling issue; using the wrong client. Removed static classes and internal referenced to PerforceScm attributes, to avoid threading issues. |
||
#6 | 8902 | Paul Allen |
Updated test cases: Pushed Workspace 'charset' to abstract Workspace class. Minor bugfixes in Workspace AutoCompletionCandidates method. |
||
#5 | 8899 | Paul Allen | Move Workspace setup/creation code to Implementation class. | ||
#4 | 8738 | Paul Allen |
Workspace Name Formatter. For Template and Stream workspaces it allows the substitution of the following tags: ${node} The name given to the slave Jenkins node. ${hostname} The hostname for the slave Jenkins node. ${project} The name of the Jenkins build Job. ${hash} Unique hash code of the Jenkins node. |
||
#3 | 8663 | Paul Allen | Rollout of charset for all Workspace modes. | ||
#2 | 8641 | Paul Allen | Added workspace helper (setClient) and template/stream types. | ||
#1 | 8640 | Paul Allen |
Added Workspace and Singleton descriptor. Removed old connection code. |