Skip to content

Commit 08714a4

Browse files
committed
1 parent 1b2ce0e commit 08714a4

File tree

10 files changed

+33
-52
lines changed

10 files changed

+33
-52
lines changed

plugin/pom.xml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,12 @@
5454
<scope>import</scope>
5555
<type>pom</type>
5656
</dependency>
57+
<!-- TODO until in BOM: -->
58+
<dependency>
59+
<groupId>org.jenkins-ci.plugins.workflow</groupId>
60+
<artifactId>workflow-step-api</artifactId>
61+
<version>656.v54853706d987</version> <!-- TODO https://github.com/jenkinsci/workflow-step-api-plugin/pull/149 -->
62+
</dependency>
5763
</dependencies>
5864
</dependencyManagement>
5965
<dependencies>
@@ -104,12 +110,6 @@
104110
</exclusion>
105111
</exclusions>
106112
</dependency>
107-
<dependency>
108-
<groupId>org.jenkins-ci.plugins.workflow</groupId>
109-
<artifactId>workflow-step-api</artifactId>
110-
<classifier>tests</classifier>
111-
<scope>test</scope>
112-
</dependency>
113113
<dependency>
114114
<groupId>org.jenkins-ci.plugins.workflow</groupId>
115115
<artifactId>workflow-support</artifactId>

plugin/src/test/java/org/jenkinsci/plugins/workflow/cps/ContextVariableSetTest.java

Lines changed: 17 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,6 @@
3939
import org.jenkinsci.plugins.workflow.job.WorkflowJob;
4040
import org.jenkinsci.plugins.workflow.job.WorkflowRun;
4141
import org.jenkinsci.plugins.workflow.log.TaskListenerDecorator;
42-
import org.jenkinsci.plugins.workflow.steps.BodyInvoker;
4342
import org.jenkinsci.plugins.workflow.steps.DynamicContext;
4443
import org.jenkinsci.plugins.workflow.steps.Step;
4544
import org.jenkinsci.plugins.workflow.steps.StepContext;
@@ -155,21 +154,20 @@ private static final class DecoratorImpl extends TaskListenerDecorator {
155154
}
156155
}
157156
private static final class YesPleaseDecorate implements Serializable {}
158-
public static final class DecoratorStep extends Step implements Serializable {
157+
public static final class DecoratorStep extends Step {
159158
@DataBoundConstructor public DecoratorStep() {}
160159
@DataBoundSetter public @CheckForNull String message;
161160
@Override public StepExecution start(StepContext context) throws Exception {
162-
return StepExecutions.block(context, this::start);
163-
}
164-
private void start(StepContext context, BodyInvoker invoker) throws Exception {
165-
if (message != null) {
166-
TaskListenerDecorator original = context.get(TaskListenerDecorator.class);
167-
DecoratorImpl subsequent = new DecoratorImpl(message);
168-
LOGGER.log(Level.INFO, "merging {0} with {1}", new Object[] {original, subsequent});
169-
invoker.withContext(TaskListenerDecorator.merge(original, subsequent));
170-
} else {
171-
invoker.withContext(new YesPleaseDecorate());
172-
}
161+
return StepExecutions.block(context, (c, invoker) -> {
162+
if (message != null) {
163+
TaskListenerDecorator original = c.get(TaskListenerDecorator.class);
164+
DecoratorImpl subsequent = new DecoratorImpl(message);
165+
LOGGER.log(Level.INFO, "merging {0} with {1}", new Object[] {original, subsequent});
166+
invoker.withContext(TaskListenerDecorator.merge(original, subsequent));
167+
} else {
168+
invoker.withContext(new YesPleaseDecorate());
169+
}
170+
});
173171
}
174172
@TestExtension("smokes") public static final class DescriptorImpl extends StepDescriptor {
175173
@Override public String getFunctionName() {
@@ -213,11 +211,10 @@ private static final class Message implements Serializable {
213211
public static final class GetMessageStep extends Step {
214212
@DataBoundConstructor public GetMessageStep() {}
215213
@Override public StepExecution start(StepContext context) throws Exception {
216-
return StepExecutions.synchronous(context, GetMessageStep::run);
217-
}
218-
private static Object run(StepContext context) throws Exception {
219-
Message message = context.get(Message.class);
220-
return message != null ? message.text : null;
214+
return StepExecutions.synchronous(context, c -> {
215+
Message message = c.get(Message.class);
216+
return message != null ? message.text : null;
217+
});
221218
}
222219
@TestExtension("dynamicVsStatic") public static final class DescriptorImpl extends StepDescriptor {
223220
@Override public String getFunctionName() {
@@ -228,7 +225,7 @@ private static Object run(StepContext context) throws Exception {
228225
}
229226
}
230227
}
231-
public static final class WithStaticMessageStep extends Step implements Serializable {
228+
public static final class WithStaticMessageStep extends Step {
232229
public final String text;
233230
@DataBoundConstructor public WithStaticMessageStep(String text) {
234231
this.text = text;
@@ -266,7 +263,7 @@ private static final class DynamicMessage implements Serializable {
266263
return dynamicMessage != null ? new Message(dynamicMessage.text) : null;
267264
}
268265
}
269-
public static final class WithDynamicMessageStep extends Step implements Serializable {
266+
public static final class WithDynamicMessageStep extends Step {
270267
public final String text;
271268
@DataBoundConstructor public WithDynamicMessageStep(String text) {
272269
this.text = text;

plugin/src/test/java/org/jenkinsci/plugins/workflow/cps/CpsFlowDefinition2Test.java

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@
3030
import hudson.model.Describable;
3131
import hudson.model.Executor;
3232
import hudson.model.Result;
33-
import java.io.Serializable;
3433
import java.util.Collections;
3534
import java.util.Set;
3635
import java.util.logging.Level;
@@ -927,17 +926,14 @@ public void scriptInitializerCallsCpsTransformedMethod() throws Exception {
927926
jenkins.assertLogContains("Scripts not permitted to use field Test metaClass", b);
928927
}
929928

930-
public static class UnsafeParameterStep extends Step implements Serializable {
929+
public static class UnsafeParameterStep extends Step {
931930
private final UnsafeDescribable val;
932931
@DataBoundConstructor
933932
public UnsafeParameterStep(UnsafeDescribable val) {
934933
this.val = val;
935934
}
936-
public StepExecution start(StepContext context) throws Exception {
937-
return StepExecutions.synchronousNonBlocking(context, c -> {
938-
val.doSomething();
939-
return null;
940-
});
935+
@Override public StepExecution start(StepContext context) throws Exception {
936+
return StepExecutions.synchronousNonBlockingVoid(context, c -> val.doSomething());
941937
}
942938
@TestExtension
943939
public static class DescriptorImpl extends StepDescriptor {

plugin/src/test/java/org/jenkinsci/plugins/workflow/cps/actions/ArgumentsActionImplTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -700,7 +700,7 @@ public static class NopStep extends Step {
700700
public NopStep(Object value) {}
701701
@Override
702702
public StepExecution start(StepContext context) throws Exception {
703-
return StepExecutions.synchronous(context, unused -> null);
703+
return StepExecutions.synchronousVoid(context, c -> {});
704704
}
705705
@TestExtension
706706
public static class DescriptorImpl extends StepDescriptor {

plugin/src/test/java/org/jenkinsci/plugins/workflow/testMetaStep/MonomorphicListStep.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,11 +27,10 @@ public MonomorphicListStep(List<MonomorphicData> data) {
2727
}
2828

2929
@Override public StepExecution start(StepContext context) throws Exception {
30-
return StepExecutions.synchronousNonBlocking(context, c -> {
30+
return StepExecutions.synchronousNonBlockingVoid(context, c -> {
3131
for (MonomorphicData d : data) {
3232
c.get(TaskListener.class).getLogger().println(d.getArgs());
3333
}
34-
return null;
3534
});
3635
}
3736

plugin/src/test/java/org/jenkinsci/plugins/workflow/testMetaStep/MonomorphicListWithSymbolStep.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,11 +27,10 @@ public MonomorphicListWithSymbolStep(List<MonomorphicDataWithSymbol> data) {
2727
}
2828

2929
@Override public StepExecution start(StepContext context) throws Exception {
30-
return StepExecutions.synchronousNonBlocking(context, c -> {
30+
return StepExecutions.synchronousNonBlockingVoid(context, c -> {
3131
for (MonomorphicDataWithSymbol d : data) {
3232
c.get(TaskListener.class).getLogger().println(d.getArgs());
3333
}
34-
return null;
3534
});
3635
}
3736

plugin/src/test/java/org/jenkinsci/plugins/workflow/testMetaStep/MonomorphicStep.java

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,10 +27,7 @@ public MonomorphicStep(MonomorphicData data) {
2727
}
2828

2929
@Override public StepExecution start(StepContext context) throws Exception {
30-
return StepExecutions.synchronousNonBlocking(context, c -> {
31-
c.get(TaskListener.class).getLogger().println(data.getArgs());
32-
return null;
33-
});
30+
return StepExecutions.synchronousNonBlockingVoid(context, c -> c.get(TaskListener.class).getLogger().println(data.getArgs()));
3431
}
3532

3633
@Extension

plugin/src/test/java/org/jenkinsci/plugins/workflow/testMetaStep/MonomorphicWithSymbolStep.java

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,10 +25,7 @@ public MonomorphicWithSymbolStep(MonomorphicDataWithSymbol data) {
2525
}
2626

2727
@Override public StepExecution start(StepContext context) throws Exception {
28-
return StepExecutions.synchronousNonBlocking(context, c -> {
29-
c.get(TaskListener.class).getLogger().println(data.getArgs());
30-
return null;
31-
});
28+
return StepExecutions.synchronousNonBlockingVoid(context, c -> c.get(TaskListener.class).getLogger().println(data.getArgs()));
3229
}
3330

3431
@Extension

plugin/src/test/java/org/jenkinsci/plugins/workflow/testMetaStep/StateMetaStep.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,13 +39,12 @@ public void setModerate(boolean m) {
3939
}
4040

4141
@Override public StepExecution start(StepContext context) throws Exception {
42-
return StepExecutions.synchronousNonBlocking(context, c -> {
42+
return StepExecutions.synchronousNonBlockingVoid(context, c -> {
4343
TaskListener listener = c.get(TaskListener.class);
4444
if (moderate) {
4545
listener.getLogger().println("Introducing " + SymbolLookup.getSymbolValue(state).iterator().next());
4646
}
4747
state.sayHello(listener);
48-
return null;
4948
});
5049
}
5150

plugin/src/test/java/org/jenkinsci/plugins/workflow/testMetaStep/chemical/DetectionMetaStep.java

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,7 @@ public DetectionMetaStep(Chemical compound) {
2626
}
2727

2828
@Override public StepExecution start(StepContext context) throws Exception {
29-
return StepExecutions.synchronousNonBlocking(context, c -> {
30-
c.get(TaskListener.class).getLogger().println("Detecting " + compound.getClass().getName());
31-
return null;
32-
});
29+
return StepExecutions.synchronousNonBlockingVoid(context, c -> c.get(TaskListener.class).getLogger().println("Detecting " + compound.getClass().getName()));
3330
}
3431

3532
@Extension(ordinal=100)

0 commit comments

Comments
 (0)