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 java.util.logging.Logger; 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.WorkspaceDescriptor; import org.jenkinsci.plugins.workflow.steps.scm.SCMStep; import org.kohsuke.stapler.DataBoundConstructor; import org.kohsuke.stapler.QueryParameter; public class P4StreamStep extends SCMStep { private static Logger logger = Logger.getLogger(P4StreamStep.class .getName()); private static final long serialVersionUID = 1L; private final String credential; private final String stream; private final String charset; @DataBoundConstructor public P4StreamStep(String credential, String stream, String charset) { this.credential = credential; this.stream = stream; this.charset = charset; } @Override protected SCM createSCM() { logger.info("Create P4 SCM"); P4WebBrowser browser = null; String format = "jenkins-${node}-${project}.ws"; StreamWorkspaceImpl workspace = new StreamWorkspaceImpl(charset, false, stream, format); Populate populate = new AutoCleanImpl(true, true, false, null); PerforceScm scm = new PerforceScm(credential, workspace, null, populate, browser); return scm; } public String getCredential() { return credential; } public String getStream() { return stream; } public String getCharset() { return charset; } @Extension(optional = true) public static final class DescriptorImpl extends SCMStepDescriptor { 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 FormValidation doCheckStream(@QueryParameter String value) { return WorkspaceDescriptor.doCheckStreamName(value); } public ListBoxModel doFillCharsetItems() { return WorkspaceDescriptor.doFillCharsetItems(); } @Override public String getFunctionName() { return "p4_stream"; } @Override public String getDisplayName() { return "P4 Stream"; } } }
# | Change | User | Description | Committed | |
---|---|---|---|---|---|
#5 | 14130 | Sven Erik Knop | Remove individual step objects, they are subsumed into P4Step | ||
#4 | 13630 | Sven Erik Knop | Fixed problem with format. | ||
#3 | 13575 | Sven Erik Knop | Added p4_template DSL | ||
#2 | 12975 | Sven Erik Knop |
Added charset completer, refactoring of WorkspaceDescriptor to avoid duplication of code. |
||
#1 | 12959 | Sven Erik Knop |
Refactored p4 to p4_stream Connection selector works, stream autocomplete works workspace default name still missing |
||
//guest/sven_erik_knop/p4jenkins/src/main/java/org/jenkinsci/plugins/p4/workflow/P4Step.java | |||||
#1 | 12958 | Sven Erik Knop |
DSL for P4 works in principle (hard coded workspace for now) Misses automatic loading of aggregator |