package org.jenkinsci.plugins.p4.groovy; import com.google.common.collect.ImmutableSet; import hudson.Extension; import hudson.FilePath; import hudson.Launcher; import hudson.model.Item; import hudson.model.Run; import hudson.model.TaskListener; import hudson.util.ListBoxModel; import org.jenkinsci.Symbol; import org.jenkinsci.plugins.p4.credentials.P4CredentialsImpl; import org.jenkinsci.plugins.p4.workspace.Workspace; import org.jenkinsci.plugins.workflow.steps.Step; import org.jenkinsci.plugins.workflow.steps.StepContext; import org.jenkinsci.plugins.workflow.steps.StepDescriptor; import org.jenkinsci.plugins.workflow.steps.StepExecution; import org.jenkinsci.plugins.workflow.steps.SynchronousNonBlockingStepExecution; import org.kohsuke.stapler.AncestorInPath; import org.kohsuke.stapler.DataBoundConstructor; import org.kohsuke.stapler.QueryParameter; import java.util.Set; public class GetP4Step extends Step { private final String credential; private final Workspace workspace; public String getCredential() { return credential; } public Workspace getWorkspace() { return workspace; } @DataBoundConstructor public GetP4Step(String credential, Workspace workspace) { this.credential = credential; this.workspace = workspace; } @Extension(optional = true) @Symbol("p4groovy") public static class DescriptorImpl extends StepDescriptor { @Override public String getFunctionName() { return "p4"; } @Override public String getDisplayName() { return "P4 Groovy"; } @Override public Set<? extends Class<?>> getRequiredContext() { return ImmutableSet.of(Run.class, FilePath.class, Launcher.class, TaskListener.class); } public ListBoxModel doFillCredentialItems(@AncestorInPath Item project, @QueryParameter String credential) { return P4CredentialsImpl.doFillCredentialItems(project, credential); } } @Override public StepExecution start(StepContext context) throws Exception { return new Execution(this, context); } public static class Execution extends SynchronousNonBlockingStepExecution<P4Groovy> { private static final long serialVersionUID = 1L; private transient GetP4Step step = null; Execution(GetP4Step step, StepContext context) { super(context); this.step = step; } @Override protected P4Groovy run() throws Exception { GetP4 p4Groovy = new GetP4(step.getCredential(), step.getWorkspace()); p4Groovy.perform(getContext().get(Run.class), getContext().get(FilePath.class), getContext().get(Launcher.class), getContext().get(TaskListener.class)); return p4Groovy.getP4Groovy(); } } }
# | Change | User | Description | Committed | |
---|---|---|---|---|---|
#7 | 28463 | Paul Allen |
FindBugs error: SE_TRANSIENT_FIELD_NOT_RESTORED (transient but isn't set by deserialisation) |
||
#6 | 26673 | Paul Allen |
Code cleanup - remove calls to Deprecated methods - Deprecated classes like AbstractStepImpl, AbstractStepDescriptorImpl and AbstractSynchronousStepExecution for P4TaggingStep |
||
#5 | 22684 | Paul Allen | Added @Symbol to Extension classes for Pipeline Syntax. | ||
#4 | 22019 | Paul Allen |
Fix TaskListener serialisation issue. TaskListener field must be transient as part of the program state, but is marked `Serializable` for the Task as it is sent over the Remoting Channel. Update p4 groovy to extend Step and not AbstractStepImpl. |
||
#3 | 21794 | Paul Allen |
Merge pull request #39 from Dohbedoh/JENKINS-34825 Jenkins 34825 |
||
#2 | 20783 | Paul Allen | Tidy up and mark as BETA | ||
#1 | 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). |