Skip to content

Commit f7ab98e

Browse files
authored
Merge pull request #258 from jglick/PushdStep
Moved `PushdStep` to `workflow-durable-task-step`
2 parents c322174 + 8bbe5fd commit f7ab98e

File tree

6 files changed

+13
-185
lines changed

6 files changed

+13
-185
lines changed

pom.xml

+6
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,11 @@
7676
<scope>import</scope>
7777
<type>pom</type>
7878
</dependency>
79+
<dependency>
80+
<groupId>org.jenkins-ci.plugins.workflow</groupId>
81+
<artifactId>workflow-durable-task-step</artifactId>
82+
<version>1227.vdc0a_d1fd4338</version> <!-- TODO until in BOM -->
83+
</dependency>
7984
</dependencies>
8085
</dependencyManagement>
8186
<dependencies>
@@ -124,6 +129,7 @@
124129
<dependency>
125130
<groupId>org.jenkins-ci.plugins.workflow</groupId>
126131
<artifactId>workflow-durable-task-step</artifactId>
132+
<scope>runtime</scope> <!-- TODO switch to test once 1227.vdc0a_d1fd4338 or later is widely adopted -->
127133
</dependency>
128134
<dependency>
129135
<groupId>org.jenkins-ci.plugins.workflow</groupId>

src/main/java/org/jenkinsci/plugins/workflow/steps/PushdStep.java

+7-69
Original file line numberDiff line numberDiff line change
@@ -24,84 +24,22 @@
2424

2525
package org.jenkinsci.plugins.workflow.steps;
2626

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-
3927
/**
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}.
4129
*/
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 {
6832

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() {}
8434

8535
public static class Execution extends AbstractStepExecutionImpl {
8636

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");
9339
}
9440

9541
@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");
10543
}
10644

10745
@Override public void onResume() {}

src/main/resources/org/jenkinsci/plugins/workflow/steps/PushdStep/config.jelly

-31
This file was deleted.

src/main/resources/org/jenkinsci/plugins/workflow/steps/PushdStep/help-path.html

-3
This file was deleted.

src/main/resources/org/jenkinsci/plugins/workflow/steps/PushdStep/help.html

-4
This file was deleted.

src/test/java/org/jenkinsci/plugins/workflow/steps/PushdStepTest.java

-78
This file was deleted.

0 commit comments

Comments
 (0)