如何在自定义的Hudson插件中的参数化构建页面上创建动态下拉列表? [英] How to make dynamic drop down lists on parameterized build page in a custom Hudson plugin?

查看:98
本文介绍了如何在自定义的Hudson插件中的参数化构建页面上创建动态下拉列表?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在为实现哈德逊参数化工作而努力实现以下目标:当用户单击立即构建"时,应该为他提供三个下拉列表参数,即环境,服务器,端口.我希望下拉列表是动态的,即在更改环境的值时,服务器列表应相应更改,并且类似地,端口的值应根据所选服务器而更改.

I am trying to achieve the following for a parameterized hudson job: when a user clicks on 'build now' he should be presented with three drop down list parameters viz., Environment, Server, Port. I want the drop down to be dynamic i.e on changing the value of environment the list of servers should change accordingly and similarly the values of port should change on the basis of selected server.

一旦用户做出了最终选择,下拉菜单中的所有三个值将被用于使单个值作为参数传递给构建作业.我一直坚持如何在单个参数中实现此目标并使它动态化.在我的自定义插件中,我扩展了ParameterDefinition类,并且在其中有一个静态嵌套类,对这三个字段使用doFillXXXItems()扩展了ParameterDescriptor类.环境下拉列表中的值是根据登录的用户名填充的.如果有人可以帮助我弄清楚如何使下拉菜单动态变化,我将不胜感激.我已经尝试过ui-samples插件中的动态下拉列表框,但是在我的情况下它不起作用:(

Once a user makes the final selection, all three values from the dropdowns are to be used to make a single value to be passed to the build job as a parameter. I am stuck at how to achieve this in a single parameter and make it dynamic. In my custom plugin i have extended the ParameterDefinition class and within it i have a static nested class extending the ParameterDescriptor class with doFillXXXItems() for these three fields. The values in environment dropdown are populated on the basis of logged in username. I would really appreciate it if somebody could help me figure out how to make the drop downs dynamic. I have already tried the dynamic drop down listbox in ui-samples plugin but its not working in my case :(

推荐答案

您可以继承 hudson.model.ChoiceParameterDefinition ,并覆盖其 getChoicesText 方法.根据您的需要返回选项,您可以根据自己的情况从 Hudson.getInstance()中获取环境.

You could inherit hudson.model.ChoiceParameterDefinition, and override its method of getChoicesText. return the options based on whatever you want, in your situation, you could get environments from Hudson.getInstance().

下面的代码片段显示了如何获取环境变量.

Below snippets is shown how get environment variable.

Hudson.getInstance().getGlobalNodeProperties()
       .get(EnvironmentVariablesNodeProperty.class).getEnvVars().get(name);

这篇关于如何在自定义的Hudson插件中的参数化构建页面上创建动态下拉列表?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆