我的插件中有2个步骤,想法是配置管道,以便首先出现myStep1,然后是用户自己的步骤,然后是myStep2,如下所示:
stage ("My Step 1"){
mystep1 foo: 'foo', bar: 'bar'
}
stage ("Users random Steps 1..n"){
// ...
}
stage ("My Step 2"){
mystep2()
}
stage ("Users Other steps 0..n"){
// ...
}
问题是我想从myStep1到myStep2中获得相同的'foo'和'bar'设置值,但是我不知道该怎么做。设置foo和bar不能用作全局设置,它们是特定于管道的。
myStep1和myStep2看起来像这样,它们各有千秋:
public class MyStep1 extends Step1 implements SimpleBuildStep {
@DataBoundConstructor
public MyStep1(String foo, String bar) {
super.foo = foo;
super.bar = bar;
}
//@DataBoundSetter
// setters and getters for foo and bar
@Override
public void perform(@Nonnull Run<?, ?> run,
@Nonnull FilePath workspace,
@Nonnull Launcher launcher,
@Nonnull TaskListener listener) throws InterruptedException, IOException {
super.perform(run, workspace, listener); // does the actual stuff
}
@Override
public Step1BuildStepDescriptor getDescriptor() {
return super.getDescriptor();
}
@Extension
@Symbol("mystep1")
public static final class Step1BuildStepDescriptor extends BuildStepDescriptor<Builder> implements ExtensionPoint {
// basic Descriptor stuff
}
}
我已经尝试使用以下答案获得之前的步骤:How can I retrieve a list of all Jenkins build steps available to a job? 当我处于myStep2的perform方法中时,可以获取myStep1的buildStepDescriptor,但可悲的是,我找不到任何方法来获取给myStep1的设置。
到目前为止,我一直在考虑: