在jenkins中使用Extended Choice Parameter插件用来显示自定义的多选项,尝试通过groovy script来显示,正常,但查看它的例子,发现它例子中多选是通过类型 Json Parameter Type
想尝试使用下,直接从帮助中拷贝了一个例子,已经是里面最简单的一个选择颜色的例子
选择类型 "JSON Parameter Type" 再选择"JSON Parameter Config Groovy Script"
把例子中的内容直接拷贝
disable_edit_json: true, disable_properties: true, no_additional_properties: true, disable_collapse: true, disable_array_add: true, disable_array_delete: true, disable_array_reorder: true, theme: "bootstrap2", iconlib:"fontawesome4", schema: { "title": "Color Picker", "type": "object", "properties": { "color": { "type": "string", "format": "color" } } },startval: { color :"red" } }/);
排版有点乱,无所谓了,反正这段是可以从插件的帮助中查询到的
照道理来说,完全拷贝的,应该可以正常运行
但拷贝后,执行,并没有显示
就很奇怪是为什么不能显示,明明配置都是拷贝过来的
然后查看jenkins的日志
java.net.MalformedURLException: JENKINS-37599: empty classpath entries not allowed应该是classpath没有设置,但如何设置classpath呢 ?
查看之后,发现我们装这个多选参数的插件的时候,有一个前置插件script-security.hpi
到jekins的目录中查找子目录 plugins,在这个目录中找到插件的目录script-security
这个插件下有一个jar包,groovy-sandbox-1.10.jar
具体的目录是 D:\Program Files (x86)\Jenkins\plugins\script-security\WEB-INF\lib\groovy-sandbox-1.10.jar
此时还是在刚才的参数设置中,选择高级,把这个jar的路径设在classpath中
此时运行,选择Build with Parameters,就可以出现颜色选择
当然这个只是拷贝了一个最简单的颜色的例子和遇到的问题
如果配置更为复制的选择,可能需要了解json schema
只是记录下,遇到的问题
本文介绍了在Jenkins中使用Extended Choice Parameter插件时遇到的问题,特别是尝试使用Json Parameter Type显示多选项时无法正常显示。通过查看日志发现由于classpath未设置导致,解决方法是添加script-security插件中的groovy-sandbox-1.10.jar到classpath。该文章记录了问题解决过程,对于需要使用复杂选择的用户,可能需要了解json schema。
1万+

被折叠的 条评论
为什么被折叠?



