package org.jenkinsci.plugins.p4.workflow; 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.FormValidation; import hudson.util.ListBoxModel; import org.jenkinsci.plugins.p4.credentials.P4CredentialsImpl; import org.jenkinsci.plugins.p4.unshelve.UnshelveBuilder; import org.jenkinsci.plugins.p4.unshelve.UnshelveBuilderStep; 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 javax.annotation.Nonnull; import java.util.Set; public class P4UnshelveStep extends Step { private final String credential; private final Workspace workspace; private final String shelf; private final String resolve; private final boolean tidy; @DataBoundConstructor public P4UnshelveStep(String credential, Workspace workspace, String shelf, String resolve, boolean tidy) { this.credential = credential; this.workspace = workspace; this.shelf = shelf; this.resolve = resolve; this.tidy = tidy; } @Deprecated public P4UnshelveStep(String shelf, String resolve) { this(null, null, shelf, resolve, false); } @Override public StepExecution start(StepContext context) throws Exception { return new P4UnshelveStepExecution(this, context); } public String getCredential() { return credential; } public Workspace getWorkspace() { return workspace; } public String getShelf() { return shelf; } public String getResolve() { return resolve; } public boolean isTidy() { return tidy; } @Extension(optional = true) public static final class DescriptorImpl extends StepDescriptor { @Override public String getFunctionName() { return "p4unshelve"; } @Override public String getDisplayName() { return "P4 Unshelve"; } @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); } public FormValidation doCheckCredential(@AncestorInPath Item project, @QueryParameter String value) { return P4CredentialsImpl.doCheckCredential(project, value); } public ListBoxModel doFillResolveItems() { return UnshelveBuilder.DescriptorImpl.doFillResolveItems(); } } public static class P4UnshelveStepExecution extends SynchronousNonBlockingStepExecution<Void> { private static final long serialVersionUID = 1L; private transient P4UnshelveStep step; protected P4UnshelveStepExecution(P4UnshelveStep step, @Nonnull StepContext context) { super(context); this.step = step; } @Override protected Void run() throws Exception { UnshelveBuilderStep unshelve = new UnshelveBuilderStep(step.getCredential(), step.getWorkspace(), step.getShelf(), step.getResolve(), step.isTidy()); unshelve.perform(getContext().get(Run.class), getContext().get(FilePath.class), getContext().get(Launcher.class), getContext().get(TaskListener.class)); return null; } } }
# | Change | User | Description | Committed | |
---|---|---|---|---|---|
#8 | 28463 | Paul Allen |
FindBugs error: SE_TRANSIENT_FIELD_NOT_RESTORED (transient but isn't set by deserialisation) |
||
#7 | 26673 | Paul Allen |
Code cleanup - remove calls to Deprecated methods - Deprecated classes like AbstractStepImpl, AbstractStepDescriptorImpl and AbstractSynchronousStepExecution for P4TaggingStep |
||
#6 | 22858 | Paul Allen |
Merge pull request #54 from mihailogazda/master. P4Unshelve build step can now be skipped successfully if the changelist ID is not set. |
||
#5 | 22684 | Paul Allen | Added @Symbol to Extension classes for Pipeline Syntax. | ||
#4 | 22315 | Paul Allen |
Pending change cleanup for unshelve. Unshelve would leave files open for add/edit/delete, the 'tidy' option will 'revert -k' the files leaving the content in the workspace, but removing the 'have' list data. Unshelve can now specify a Credential and Workspace, important for situations where more than one sync occurs in a pipeline script. JENKINS-43430 |
||
#3 | 22305 | Paul Allen | Update Unshelve Step to use 'Step' and 'SynchronousNonBlockingStepExecution' | ||
#2 | 20593 | Paul Allen |
Unshelve options in Pipeline. Update merge options and support unshelve ListBoxModel Option in Pipeline. |
||
#1 | 16529 | Paul Allen |
DSL for Unshelve task. DSL example: p4unshelve resolve: 'at', shelf: '10831' |