如何从optionalblock从jelly到java获取文本框的值?

如何从optionalblock从jelly到java获取文本框的值?,java,xml,jenkins-plugins,jelly,Java,Xml,Jenkins Plugins,Jelly,我刚开始用Jelly编写代码,我有一个问题: 我想打印我在文本框中写的值。文本框位于我选中的optionalblock中。但当我想打印它的值时,它会打印“null”。我想这个值没有被保存,或者我必须检查支票盒是否被选中。。。 这是我的密码,谢谢你的帮助 config.jelly HelloWorldBuilder.java public class HelloWorldBuilder extends Builder { private final String paramet

我刚开始用Jelly编写代码,我有一个问题: 我想打印我在文本框中写的值。文本框位于我选中的optionalblock中。但当我想打印它的值时,它会打印“null”。我想这个值没有被保存,或者我必须检查支票盒是否被选中。。。 这是我的密码,谢谢你的帮助

config.jelly


HelloWorldBuilder.java

public class HelloWorldBuilder extends Builder {

    private final String parameter_name;

    /**
     * This annotation tells Hudson to call this constructor, with
     * values from the configuration form page with matching parameter names.
     */
    @DataBoundConstructor
    public HelloWorldBuilder(String parameter_name) {
        this.parameter_name = parameter_name;
    }

    /**
     * We'll use this from the <tt>config.jelly</tt>.
     */
    public String getParameter_ame() {
        return parameter_name;
    }

    @Override
    public boolean perform(AbstractBuild build, Launcher launcher, BuildListener listener) throws IOException {
        // this is where you 'build' the project
        // since this is a dummy, we just say 'hello world' and call that a build

        listener.getLogger().println("Parameter name = " + parameter_name + "!");
        build.save();
        return true;
    }
公共类HelloWorldBuilder扩展生成器{
私有最终字符串参数_name;
/**
*这个注释告诉Hudson调用这个构造函数,使用
*配置表单页面中具有匹配参数名称的值。
*/
@数据边界构造函数
公共HelloWorldBuilder(字符串参数_名称){
this.parameter\u name=parameter\u name;
}
/**
*我们将从config.jelly中使用它。
*/
公共字符串getParameter_ame(){
返回参数名称;
}
@凌驾
公共布尔执行(AbstractBuild-build、Launcher-Launcher、BuildListener-listener)抛出IOException{
//这是您“构建”项目的地方
//由于这是一个虚拟的,我们只需说“hello world”,并称之为构建
listener.getLogger().println(“参数名=“+参数名+”!”);
build.save();
返回true;
}

我看到一个输入错误
公共字符串getParameter\u-ame(){
应该是
公共字符串getParameter\u-name(){
。但不确定这在这种情况下有多重要。抱歉,我的错误。我在问了这个问题后修复了它。但它仍然不起作用…我看到一个输入错误
公共字符串getParameter\u-ame(){
应该是
公共字符串getParameter_name(){
。但是,不确定这在本例中有多重要。抱歉,我的错误。我在问了这个问题后修复了它。但它仍然不起作用。。。
public class HelloWorldBuilder extends Builder {

    private final String parameter_name;

    /**
     * This annotation tells Hudson to call this constructor, with
     * values from the configuration form page with matching parameter names.
     */
    @DataBoundConstructor
    public HelloWorldBuilder(String parameter_name) {
        this.parameter_name = parameter_name;
    }

    /**
     * We'll use this from the <tt>config.jelly</tt>.
     */
    public String getParameter_ame() {
        return parameter_name;
    }

    @Override
    public boolean perform(AbstractBuild build, Launcher launcher, BuildListener listener) throws IOException {
        // this is where you 'build' the project
        // since this is a dummy, we just say 'hello world' and call that a build

        listener.getLogger().println("Parameter name = " + parameter_name + "!");
        build.save();
        return true;
    }