|
24 | 24 |
|
25 | 25 | package org.jenkinsci.plugins.workflow.steps;
|
26 | 26 |
|
27 |
| -import edu.umd.cs.findbugs.annotations.NonNull; |
28 |
| -import edu.umd.cs.findbugs.annotations.SuppressFBWarnings; |
29 |
| -import hudson.Extension; |
30 |
| -import hudson.FilePath; |
31 |
| -import hudson.model.TaskListener; |
32 |
| -import org.jenkinsci.plugins.workflow.support.steps.FilePathDynamicContext; |
33 |
| -import org.kohsuke.stapler.DataBoundConstructor; |
34 |
| - |
35 |
| -import java.util.Collections; |
36 |
| -import java.util.HashSet; |
37 |
| -import java.util.Set; |
38 |
| - |
39 | 27 | /**
|
40 |
| - * Temporarily changes the working directory. |
| 28 | + * @deprecated Only exists as a placeholder for old running builds; now {@code org.jenkinsci.plugins.workflow.support.steps.PushdStep}. |
41 | 29 | */
|
42 |
| -public class PushdStep extends Step { |
43 |
| - |
44 |
| - private final String path; |
45 |
| - |
46 |
| - @DataBoundConstructor public PushdStep(String path) { |
47 |
| - this.path = path; |
48 |
| - } |
49 |
| - |
50 |
| - public String getPath() { |
51 |
| - return path; |
52 |
| - } |
53 |
| - |
54 |
| - @Override public StepExecution start(StepContext context) throws Exception { |
55 |
| - return new Execution(path, context); |
56 |
| - } |
57 |
| - |
58 |
| - @Extension public static final class DescriptorImpl extends StepDescriptor { |
59 |
| - |
60 |
| - @Override public String getFunctionName() { |
61 |
| - return "dir"; |
62 |
| - } |
63 |
| - |
64 |
| - @NonNull |
65 |
| - @Override public String getDisplayName() { |
66 |
| - return "Change current directory"; |
67 |
| - } |
| 30 | +@Deprecated |
| 31 | +public class PushdStep { |
68 | 32 |
|
69 |
| - @Override public boolean takesImplicitBlockArgument() { |
70 |
| - return true; |
71 |
| - } |
72 |
| - |
73 |
| - @Override public Set<? extends Class<?>> getRequiredContext() { |
74 |
| - Set<Class<?>> context = new HashSet<>(); |
75 |
| - Collections.addAll(context, TaskListener.class, FilePath.class); |
76 |
| - return Collections.unmodifiableSet(context); |
77 |
| - } |
78 |
| - |
79 |
| - @Override public Set<? extends Class<?>> getProvidedContext() { |
80 |
| - return Collections.singleton(FilePath.class); |
81 |
| - } |
82 |
| - |
83 |
| - } |
| 33 | + private PushdStep() {} |
84 | 34 |
|
85 | 35 | public static class Execution extends AbstractStepExecutionImpl {
|
86 | 36 |
|
87 |
| - @SuppressFBWarnings(value="SE_TRANSIENT_FIELD_NOT_RESTORED", justification="Only used when starting.") |
88 |
| - private transient final String path; |
89 |
| - |
90 |
| - Execution(String path, StepContext context) { |
91 |
| - super(context); |
92 |
| - this.path = path; |
| 37 | + private Execution() { |
| 38 | + throw new AssertionError("only deserialized"); |
93 | 39 | }
|
94 | 40 |
|
95 | 41 | @Override public boolean start() throws Exception {
|
96 |
| - FilePath dir = getContext().get(FilePath.class).child(path); |
97 |
| - getContext().get(TaskListener.class).getLogger().println("Running in " + dir); |
98 |
| - getContext().newBodyInvoker() |
99 |
| - // TODO perhaps should just be moved into workflow-durable-task-step? |
100 |
| - .withContext(FilePathDynamicContext.createContextualObject(dir)) |
101 |
| - // Could use a dedicated BodyExecutionCallback here if we wished to print a message at the end ("Returning to ${cwd}"): |
102 |
| - .withCallback(BodyExecutionCallback.wrap(getContext())) |
103 |
| - .start(); |
104 |
| - return false; |
| 42 | + throw new AssertionError("only deserialized"); |
105 | 43 | }
|
106 | 44 |
|
107 | 45 | @Override public void onResume() {}
|
|
0 commit comments