Skip to content

Commit 16ae2a8

Browse files
committed
Fix deprecations, avoid @Inject
1 parent f6091ab commit 16ae2a8

File tree

10 files changed

+280
-328
lines changed

10 files changed

+280
-328
lines changed

plugin/src/main/java/org/jenkinsci/plugins/workflow/cps/steps/LoadStep.java

Lines changed: 19 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,21 @@
11
package org.jenkinsci.plugins.workflow.cps.steps;
22

33
import hudson.Extension;
4-
import org.jenkinsci.plugins.workflow.steps.AbstractStepDescriptorImpl;
5-
import org.jenkinsci.plugins.workflow.steps.AbstractStepImpl;
4+
import hudson.FilePath;
5+
import hudson.model.TaskListener;
6+
import java.util.Set;
7+
import org.jenkinsci.plugins.workflow.steps.Step;
8+
import org.jenkinsci.plugins.workflow.steps.StepContext;
9+
import org.jenkinsci.plugins.workflow.steps.StepDescriptor;
10+
import org.jenkinsci.plugins.workflow.steps.StepExecution;
611
import org.kohsuke.stapler.DataBoundConstructor;
712

813
/**
914
* Evaluate arbitrary script file.
1015
*
1116
* @author Kohsuke Kawaguchi
1217
*/
13-
public class LoadStep extends AbstractStepImpl {
18+
public class LoadStep extends Step {
1419
/**
1520
* Relative path of the script within the current workspace.
1621
*/
@@ -25,11 +30,13 @@ public String getPath() {
2530
return path;
2631
}
2732

33+
@Override
34+
public StepExecution start(StepContext context) throws Exception {
35+
return new LoadStepExecution(this, context);
36+
}
37+
2838
@Extension
29-
public static class DescriptorImpl extends AbstractStepDescriptorImpl {
30-
public DescriptorImpl() {
31-
super(LoadStepExecution.class);
32-
}
39+
public static class DescriptorImpl extends StepDescriptor {
3340

3441
@Override
3542
public String getFunctionName() {
@@ -40,6 +47,11 @@ public String getFunctionName() {
4047
public String getDisplayName() {
4148
return "Evaluate a Groovy source file into the Pipeline script";
4249
}
50+
51+
@Override
52+
public Set<? extends Class<?>> getRequiredContext() {
53+
return Set.of(FilePath.class, TaskListener.class);
54+
}
4355
}
4456

4557
}

plugin/src/main/java/org/jenkinsci/plugins/workflow/cps/steps/LoadStepExecution.java

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
package org.jenkinsci.plugins.workflow.cps.steps;
22

3-
import com.google.inject.Inject;
43
import groovy.lang.Script;
54
import hudson.FilePath;
65
import hudson.model.TaskListener;
@@ -12,26 +11,27 @@
1211
import org.jenkinsci.plugins.workflow.cps.replay.ReplayAction;
1312
import org.jenkinsci.plugins.workflow.steps.AbstractStepExecutionImpl;
1413
import org.jenkinsci.plugins.workflow.steps.BodyExecutionCallback;
15-
import org.jenkinsci.plugins.workflow.steps.StepContextParameter;
14+
import org.jenkinsci.plugins.workflow.steps.StepContext;
1615

1716
/**
1817
* Loads another Groovy script file and executes it.
1918
*
2019
* @author Kohsuke Kawaguchi
2120
*/
2221
public class LoadStepExecution extends AbstractStepExecutionImpl {
23-
@StepContextParameter
24-
private transient FilePath cwd;
2522

26-
@Inject(optional=true)
2723
private transient LoadStep step;
2824

29-
@StepContextParameter
30-
private transient TaskListener listener;
25+
LoadStepExecution(LoadStep step, StepContext context) {
26+
super(context);
27+
this.step = step;
28+
}
3129

3230
@Override
3331
public boolean start() throws Exception {
3432
CpsStepContext cps = (CpsStepContext) getContext();
33+
FilePath cwd = cps.get(FilePath.class);
34+
TaskListener listener = cps.get(TaskListener.class);
3535
CpsThread t = CpsThread.current();
3636

3737
CpsFlowExecution execution = t.getExecution();
@@ -62,6 +62,11 @@ public boolean start() throws Exception {
6262
return false;
6363
}
6464

65+
@Override
66+
public void onResume() {
67+
// do nothing
68+
}
69+
6570
private static final long serialVersionUID = 1L;
6671

6772
}

0 commit comments

Comments
 (0)