package org.jenkinsci.plugins.p4.workspace; import hudson.Extension; import hudson.util.FormValidation; import java.io.Serializable; import java.util.logging.Logger; import org.kohsuke.stapler.DataBoundConstructor; import org.kohsuke.stapler.QueryParameter; import com.perforce.p4java.client.IClient; import com.perforce.p4java.impl.mapbased.client.Client; import com.perforce.p4java.option.server.SwitchClientViewOptions; import com.perforce.p4java.server.IOptionsServer; public class TemplateWorkspaceImpl extends Workspace implements Serializable { private static final long serialVersionUID = 1L; private final String templateName; private final String format; private static Logger logger = Logger.getLogger(TemplateWorkspaceImpl.class .getName()); public String getTemplateName() { return templateName; } public String getFormat() { return format; } @Override public String getName() { return format; } @Override public WorkspaceType getType() { return WorkspaceType.TEMPLATED; } @DataBoundConstructor public TemplateWorkspaceImpl(String charset, boolean pinHost, String templateName, String format) { super(charset, pinHost); this.templateName = templateName; this.format = format; } @Override public IClient setClient(IOptionsServer connection, String user) throws Exception { // Expand env variables in Template name Expand expand = getExpand(); String template = expand.format(getTemplateName(), false); // Check template exists or exit early IClient itemplate = connection.getClient(template); if (itemplate == null) { return null; } // expands Workspace name if formatters are used. String clientName = getFullName(); IClient iclient = connection.getClient(clientName); if (iclient == null) { logger.info("P4: Creating template client: " + clientName); Client implClient = new Client(connection); implClient.setName(clientName); implClient.setOwnerName(user); connection.createClient(implClient); iclient = connection.getClient(clientName); } // Owner set for use with p4maven iclient.setOwnerName(user); // set line endings explicitly (JENKINS-28760) iclient.setLineEnd(itemplate.getLineEnd()); // set options explicitly (JENKINS-30546) iclient.setOptions(itemplate.getOptions()); // Root required to switch view; must reload values in iclient. iclient.setRoot(getRootPath()); iclient.update(); // Use template with client SwitchClientViewOptions opts = new SwitchClientViewOptions(); opts.setForce(true); connection.switchClientView(template, clientName, opts); iclient = connection.getClient(clientName); return iclient; } @Extension public static final class DescriptorImpl extends WorkspaceDescriptor { @Override public String getDisplayName() { return "Template (view generated for each node)"; } public FormValidation doCheckTemplateName(@QueryParameter String value) { return checkClientName(value); } } }
# | Change | User | Description | Committed | |
---|---|---|---|---|---|
#19 | 29472 | Paul Allen |
Merge pull request #173 from skumar7322/TemplateWorkspaceIssue. Polling should not set client root to Null. JENKINS-59300 |
||
#18 | 26204 | Paul Allen |
Merge pull request #111 from p4charu/jenkinsci-master JENKINS-60144: Check if the template ws exists when deleting jenkins project |
||
#17 | 25115 | Paul Allen |
Merge pull request #91 from p4charu/jenkinsci-master Fixed JENKINS-39107 and JENKINS-55826 |
||
#16 | 24777 | Paul Allen |
Global Library to use UUID for client name and delete after use. Add a new 'Delete the Perforce Client after checkout' option (for Manual clients) which normaly is false, but set to true for Global Library checkouts. JENKINS-50975 |
||
#15 | 23372 | Paul Allen | Add setter to modify workspace name and spec. | ||
#14 | 22684 | Paul Allen | Added @Symbol to Extension classes for Pipeline Syntax. | ||
#13 | 22043 | Paul Allen |
Access remote Channel to find NODE_NAME If NODE_NAME is not set in the environment, look at the remote channel, then default to 'master'. JENKINS-34128 JENKINS-43551 |
||
#12 | 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). |
||
#11 | 16628 | Paul Allen |
Set the Client Owner field on update as well as creation. (support for p4maven) |
||
#10 | 16625 | Paul Allen | Set the Workspace Owner at creation (not on update). | ||
#9 | 15879 | Paul Allen |
Copy IClientOptions explicitly. JENKINS-30546 |
||
#8 | 15491 | Paul Allen |
This fix is to expand the Template name. @mjoubert When using a Template the name does not expand (unlike the client name) if it contains variables. This is also the case for when using a stream that has ${x} variables so it also needs to be fixed there. |
||
#7 | 15379 | Paul Allen |
Ground-work for Workflow-DSL (Split out Sven’s DSL changes to the core) @sven_erik_knop |
||
#6 | 13795 | Paul Allen | (matthauck) Fix JENKINS-28760: Set line endings explicitly for template workspaces | ||
#5 | 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. |
||
#4 | 10854 | Paul Allen |
Clone Workspace Object Seems Jenkins makes re-entrant calls to the PerforceScm Object and caused the Workspace Object to get trampled. JENKINS-25547 |
||
#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/TemplateWorkspaceImpl.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/TemplateWorkspaceImpl.java | |||||
#13 | 9495 | Paul Allen |
Fix Polling issue; using the wrong client. Removed static classes and internal referenced to PerforceScm attributes, to avoid threading issues. |
||
#12 | 9040 | Paul Allen | Sets the workspace 'Owner' field when generating a workspace for Template/Stream modes. | ||
#11 | 8929 | Paul Allen |
Clean up doCheck Warnings on configuration page (TPI-80). - Added check exceptions to log as warnings. |
||
#10 | 8926 | Paul Allen |
Bug fix when unshelving files with the Template workspace option. p4-java was unable to switch the worksapce view (without the -f flag) if there were files open. - Improved logging (as this error was hidden) - Added test case for this condition. |
||
#9 | 8902 | Paul Allen |
Updated test cases: Pushed Workspace 'charset' to abstract Workspace class. Minor bugfixes in Workspace AutoCompletionCandidates method. |
||
#8 | 8899 | Paul Allen | Move Workspace setup/creation code to Implementation class. | ||
#7 | 8896 | Paul Allen | Moved common method 'doFillCharsetItems' into abstract class 'WorkspaceDescriptor'. | ||
#6 | 8771 | Paul Allen |
Perforce Server 12.1 min check for: Build configuration and password/ticket credentials. Includes: - Added logging for Perforce connections (fine) and set connection pool to 2. - Add 'none' to empty charset list (connection bug?) - Supress P4Java errors for syncing ubinary, xtext, unicode |
||
#5 | 8769 | Paul Allen | Update to charset option for workspaces to use a drop-down select with a default of 'none'. | ||
#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 | 8662 | Paul Allen | Added auto fill and checks for streams and templates. | ||
#1 | 8641 | Paul Allen | Added workspace helper (setClient) and template/stream types. |