package org.jenkinsci.plugins.p4_client.workspace; import hudson.Extension; import hudson.model.AutoCompletionCandidates; import hudson.util.FormValidation; import hudson.util.ListBoxModel; import java.util.List; import org.jenkinsci.plugins.p4_client.client.ConnectionFactory; import org.kohsuke.stapler.DataBoundConstructor; import org.kohsuke.stapler.QueryParameter; import com.perforce.p4java.client.IClient; import com.perforce.p4java.client.IClientSummary; import com.perforce.p4java.server.IOptionsServer; public class TemplateWorkspaceImpl extends Workspace { private final String charset; private final String templateName; private final String format; public String getCharset() { return charset; } public String getTemplateName() { return templateName; } public String getFormat() { return format; } @Override public WorkspaceType getType() { return WorkspaceType.TEMPLATED; } @DataBoundConstructor public TemplateWorkspaceImpl(String charset, String templateName, String format) { this.charset = charset; this.templateName = templateName; this.format = format; } @Extension public static final class DescriptorImpl extends WorkspaceDescriptor { public static final String defaultFormat = "jenkins-${node}-${project}"; @Override public String getDisplayName() { return "Template (view generated for each node)"; } /** * Provides auto-completion for workspace names. Stapler finds this * method via the naming convention. * * @param value * The text that the user entered. */ public AutoCompletionCandidates doAutoCompleteTemplateName( @QueryParameter String value) { AutoCompletionCandidates c = new AutoCompletionCandidates(); try { IOptionsServer iserver = ConnectionFactory.getConnection(); if (iserver != null && value.length() > 0) { String user = iserver.getUserName(); List<IClientSummary> list; list = iserver.getClients(user, value + "*", 10); for (IClientSummary l : list) { c.add(l.getName()); } } } catch (Exception e) { } return c; } public FormValidation doCheckTemplateName(@QueryParameter String value) { try { IOptionsServer p4 = ConnectionFactory.getConnection(); IClient client = p4.getClient(value); if (client != null) { return FormValidation.ok(); } return FormValidation.error("Unknown Client: " + value); } catch (Exception e) { return FormValidation.error("Perforce connection error."); } } public FormValidation doCheckFormat(@QueryParameter final String value) { if (value == null || value.isEmpty()) return FormValidation .error("Workspace Name format is mandatory."); for (String l : ClientTags.getTags()) { if (value.contains("${" + l + "}")) { return FormValidation.ok(); } } return FormValidation.error("Workspace Name format error."); } } /** * Builds Workspace name from prefix, node and project. * * @return */ @Override public String getName() { return ClientTags.getFormattedName(format); } }
# | Change | User | Description | Committed | |
---|---|---|---|---|---|
#14 | 9672 | Paul Allen | Refactor name from 'p4_client' to 'p4'. | ||
#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. |