Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/jenkins/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Jenkins插件:连接jelly和java_Java_Jenkins_Hudson_Jenkins Plugins_Jelly - Fatal编程技术网

Jenkins插件:连接jelly和java

Jenkins插件:连接jelly和java,java,jenkins,hudson,jenkins-plugins,jelly,Java,Jenkins,Hudson,Jenkins Plugins,Jelly,我目前正在开发我的第一个Jenkins插件 我需要在job页面上有一个下拉菜单,该菜单通过java方法填充,但是jelly和java文件似乎不能正常工作 jobMain.jelly <j:jelly xmlns:j="jelly:core" xmlns:st="jelly:stapler" xmlns:d="jelly:define" xmlns:l="/lib/layout" xmlns:t="/lib/hudson" xmlns:f="/lib/form"> <h2>

我目前正在开发我的第一个Jenkins插件
我需要在job页面上有一个下拉菜单,该菜单通过java方法填充,但是jelly和java文件似乎不能正常工作

jobMain.jelly

<j:jelly xmlns:j="jelly:core" xmlns:st="jelly:stapler" xmlns:d="jelly:define" xmlns:l="/lib/layout" xmlns:t="/lib/hudson" xmlns:f="/lib/form">
<h2>FooBar</h2>
    <f:entry field="selection" title="Choose">
        <f:select />
    </f:entry>
</j:jelly>

福巴

JavaClass.java

public class JavaClass implements Action {

private AbstractProject ap;

public JavaClass(AbstractProject ap) {
    this.ap = ap;
}

public String getIconFileName() {
    return null;
}

public String getDisplayName() {
    return "";
}

public String getUrlName() {
    return "something";
}

@Extension
public static final class DescriptorImpl extends TransientProjectActionFactory {

    String selection;

    public DescriptorImpl() throws IOException {
    }

    @DataBoundConstructor
    public DescriptorImpl(String selection) {
        this.selection = selection;
    }

    public ListBoxModel doFillSelectionItems() throws IOException {
        ListBoxModel model = new ListBoxModel();
        model.add("test");
        return model;
    }

    @Override
    public Collection<? extends Action> createFor(AbstractProject target) {
        return Arrays.asList(new JavaClass(target));
    }
  }
}
public类JavaClass实现动作{
私人项目ap;
公共JavaClass(抽象项目ap){
this.ap=ap;
}
公共字符串getIconFileName(){
返回null;
}
公共字符串getDisplayName(){
返回“”;
}
公共字符串getUrlName(){
返回“某物”;
}
@延伸
公共静态最终类描述符RIMPL扩展了TransientProjectActionFactory{
字符串选择;
公共描述符rimpl()引发IOException{
}
@数据边界构造函数
公共描述符RIMPL(字符串选择){
this.selection=选择;
}
public ListBoxModel doFillSelectionItems()引发IOException异常{
ListBoxModel模型=新的ListBoxModel();
模型。添加(“测试”);
收益模型;
}
@凌驾

公共集合添加选项对象,而不是传递字符串

model.add(new Option("Test"));