Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[FIXED JENKINS-29711] Handle monomorphic single-parameters to steps.
- Loading branch information
Showing
5 changed files
with
123 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
26 changes: 26 additions & 0 deletions
26
src/test/java/org/jenkinsci/plugins/workflow/testMetaStep/MonomorphicData.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
package org.jenkinsci.plugins.workflow.testMetaStep; | ||
|
||
import hudson.Extension; | ||
import hudson.model.AbstractDescribableImpl; | ||
import hudson.model.Descriptor; | ||
import org.kohsuke.stapler.DataBoundConstructor; | ||
|
||
public class MonomorphicData extends AbstractDescribableImpl<MonomorphicData> { | ||
public final String firstArg; | ||
|
||
public final String secondArg; | ||
|
||
@DataBoundConstructor | ||
public MonomorphicData(String firstArg, String secondArg) { | ||
this.firstArg = firstArg; | ||
this.secondArg = secondArg; | ||
} | ||
|
||
public String getArgs() { | ||
return "First arg: " + firstArg + ", second arg: " + secondArg; | ||
} | ||
|
||
@Extension | ||
public static class DescriptorImpl extends Descriptor<MonomorphicData> { | ||
} | ||
} |
57 changes: 57 additions & 0 deletions
57
src/test/java/org/jenkinsci/plugins/workflow/testMetaStep/MonomorphicStep.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
package org.jenkinsci.plugins.workflow.testMetaStep; | ||
|
||
import com.google.inject.Inject; | ||
import hudson.Extension; | ||
import hudson.model.TaskListener; | ||
import org.jenkinsci.plugins.workflow.DSLTest; | ||
import org.jenkinsci.plugins.workflow.steps.AbstractStepDescriptorImpl; | ||
import org.jenkinsci.plugins.workflow.steps.AbstractStepImpl; | ||
import org.jenkinsci.plugins.workflow.steps.AbstractSynchronousNonBlockingStepExecution; | ||
import org.jenkinsci.plugins.workflow.steps.StepContextParameter; | ||
import org.kohsuke.stapler.DataBoundConstructor; | ||
|
||
/** | ||
* @author Andrew Bayer | ||
* @see DSLTest | ||
*/ | ||
public class MonomorphicStep extends AbstractStepImpl { | ||
|
||
public final MonomorphicData data; | ||
|
||
@DataBoundConstructor | ||
public MonomorphicStep(MonomorphicData data) { | ||
this.data = data; | ||
} | ||
|
||
private static final class Execution extends AbstractSynchronousNonBlockingStepExecution<Void> { | ||
@Inject | ||
private transient MonomorphicStep step; | ||
@StepContextParameter | ||
private transient TaskListener listener; | ||
|
||
@Override protected Void run() throws Exception { | ||
listener.getLogger().println(step.data.getArgs()); | ||
return null; | ||
} | ||
|
||
private static final long serialVersionUID = 1L; | ||
|
||
} | ||
|
||
@Extension | ||
public static final class DescriptorImpl extends AbstractStepDescriptorImpl { | ||
public DescriptorImpl() { | ||
super(Execution.class); | ||
} | ||
|
||
@Override public String getFunctionName() { | ||
return "monomorphStep"; | ||
} | ||
|
||
@Override public String getDisplayName() { | ||
return "Testing monomorphic single parameter."; | ||
} | ||
} | ||
|
||
|
||
} |