package org.jenkinsci.plugins.p4.workflow; import hudson.Extension; import hudson.model.AutoCompletionCandidates; import hudson.scm.SCM; import hudson.util.FormValidation; import hudson.util.ListBoxModel; import org.jenkinsci.plugins.p4.PerforceScm; import org.jenkinsci.plugins.p4.browsers.P4WebBrowser; import org.jenkinsci.plugins.p4.credentials.P4CredentialsImpl; import org.jenkinsci.plugins.p4.populate.AutoCleanImpl; import org.jenkinsci.plugins.p4.populate.Populate; import org.jenkinsci.plugins.p4.workspace.StreamWorkspaceImpl; import org.jenkinsci.plugins.p4.workspace.Workspace; import org.jenkinsci.plugins.p4.workspace.WorkspaceDescriptor; import org.jenkinsci.plugins.workflow.steps.scm.SCMStep; import org.kohsuke.stapler.DataBoundConstructor; import org.kohsuke.stapler.DataBoundSetter; import org.kohsuke.stapler.QueryParameter; public class P4Step extends SCMStep { private static final long serialVersionUID = 1L; private final String credential; private String stream = ""; private String path = ""; private String template = ""; private String charset = ""; private String format = DescriptorImpl.defaultFormat; @DataBoundConstructor public P4Step(String credential) { this.credential = credential; } public String getStream() { return stream; } @DataBoundSetter public void setStream(String stream) { this.stream = stream; } public String getPath() { return path; } @DataBoundSetter public void setPath(String path) { this.path = path; } public String getTemplate() { return template; } @DataBoundSetter public void setTemplate(String template) { this.template = template; } public String getCharset() { return charset; } @DataBoundSetter public void setCharset(String charset) { this.charset = charset; } public String getFormat() { return format; } @DataBoundSetter public void setFormat(String format) { this.format = format; } public String getCredential() { return credential; } @Override protected SCM createSCM() { P4WebBrowser browser = null; Workspace workspace = new StreamWorkspaceImpl(charset, false, stream, format); // TODO: add populate options? Populate populate = new AutoCleanImpl(true, true, false, false, null); PerforceScm scm = new PerforceScm(credential, workspace, null, populate, browser); return scm; } @Extension(optional = true) public static final class DescriptorImpl extends SCMStepDescriptor { public static final String defaultFormat = "jenkins-${NODE_NAME}-${JOB_NAME}"; public DescriptorImpl() { // Fail now if dependency plugin not loaded. Descriptor.<init> will // actually fail anyway, but this is just to be sure. PerforceScm.class.hashCode(); } /** * Credentials list, a Jelly config method for a build job. * * @return A list of Perforce credential items to populate the jelly * Select list. */ public ListBoxModel doFillCredentialItems() { return P4CredentialsImpl.doFillCredentialItems(); } public FormValidation doCheckCredential(@QueryParameter String value) { return P4CredentialsImpl.doCheckCredential(value); } public AutoCompletionCandidates doAutoCompleteStream( @QueryParameter String value) { return WorkspaceDescriptor.doAutoCompleteStreamName(value); } public AutoCompletionCandidates doAutoCompleteTemplate( @QueryParameter String value) { return WorkspaceDescriptor.doAutoCompleteTemplateName(value); } public FormValidation doCheckTemplateName(@QueryParameter String value) { return WorkspaceDescriptor.checkClientName(value); } public FormValidation doCheckStream(@QueryParameter String value) { return WorkspaceDescriptor.doCheckStreamName(value); } public ListBoxModel doFillCharsetItems() { return WorkspaceDescriptor.doFillCharsetItems(); } @Override public String getFunctionName() { return "p4"; } @Override public String getDisplayName() { return "P4"; } } }
# | Change | User | Description | Committed | |
---|---|---|---|---|---|
#7 | 15216 | Sven Erik Knop | Simple implementation of depot path for DSL | ||
#6 | 14133 | Sven Erik Knop | Added p4tag to the DSL part | ||
#5 | 14070 | Sven Erik Knop | Improved fill and check options | ||
#4 | 14052 | Sven Erik Knop | Fixed verification of source for P4: stream, template or path | ||
#3 | 14014 | Sven Erik Knop |
Single P4 Step works, but needs validation of fields for snippet generator |
||
#2 | 12959 | Sven Erik Knop |
Refactored p4 to p4_stream Connection selector works, stream autocomplete works workspace default name still missing |
||
#1 | 12958 | Sven Erik Knop |
DSL for P4 works in principle (hard coded workspace for now) Misses automatic loading of aggregator |