Dynamic select lists for parameter plugins

825 views
Skip to first unread message

Tekante

unread,
Jan 26, 2012, 12:38:15 PM1/26/12
to Jenkins Developers
I'm working on a plugin where I would like to provide the ability to
specify two parameters using the same UI as the DynamicDropDownListBox
in the UI samples plugin. I'm running into a problem where I'm getting
the "This page expects a form submission" error metioned here:
https://issues.jenkins-ci.org/browse/JENKINS-2781. I'm a bit stuck on
debugging and wonder if someone could point me in the right direction.

From looking at my browser request versus what is made for the UI
sample it seems like I haven't declared the right amount of data for
Jenkins to construct a proper URL request for getting the data from my
doFillXyzItems method but based on this thread:
http://groups.google.com/group/jenkinsci-dev/browse_thread/thread/d3d3fee462b56d6e/dfd6179390aa2bd0?lnk=gst&q=ajax#dfd6179390aa2bd0
I think I would be seeing a different error if the doFillXyzItems
method was the problem.

My plugin code is here: https://github.com/tekante/Dynamic-Jenkins-Parameter.
At the moment, it is simply trying to populate the select item
correctly.

When I try to run a build, on the parameter page I see a browser
request to: http://localhost:8080/job/Dynamic%20Parameter/build?delay=0sec
with no post data and a 400 response along with the following in my
Jenkins console

[Winstone 2012/01/26 12:25:21] - Untrapped Error in Servlet
javax.servlet.ServletException: java.lang.Error: This page expects a
form submission
at org.kohsuke.stapler.Stapler.tryInvoke(Stapler.java:605)
at org.kohsuke.stapler.Stapler.invoke(Stapler.java:648)
at org.kohsuke.stapler.MetaClass$6.doDispatch(MetaClass.java:241)
.... trimmed

The select list for my parameter is also not correclty populated.

Based on what I see in the UI Samples, a post to
http://localhost:8080/descriptorByName/hudson.plugins.ui_samples.DynamicDropDownListBox/fillStateItems
I was expecting to see a request like
http://localhost:8080/job/Dynamic%20Parameter/descriptorByName/com.tekante.jenkins.DynamicParamter/fillValueItems

Is there some documentation that can clarify what needs to be done to
hook up the <f:select /> item in my jelly template to populate based
on the doFillValueItems() method in my plugin's descriptor?

Thanks,
Chris

Tekante

unread,
Feb 1, 2012, 11:01:17 AM2/1/12
to Jenkins Developers
I've determined that the cause of my issue was a missing variable
declaration in my index.jelly template to set the instance and
descriptor variables before my <f:select /> item.

I've been able to get the parameter setting portion of the plugin
working though it seems that the way I have to get from the
doFillValueItems method in my descriptor back to the instance of my
parameter definition is not optimal. It also leads to a condition
where I'm not able to have more than one of my dynamic parameters in a
configuration screen because I can't distinguish which instance to
pull the configuration from.

I'm doing the following to get the parameter definition from within my
doFillValueItems method, is there a better way?

String containsJobName = getCurrentDescriptorByNameUrl();
String jobName =
java.net.URLDecoder.decode(containsJobName.substring(containsJobName.lastIndexOf("/")
+ 1));
Job<?,?> j = Hudson.getInstance().getItemByFullName(jobName,
hudson.model.Job.class);
if (j != null) {
ParametersDefinitionProperty pdp =
j.getProperty(hudson.model.ParametersDefinitionProperty.class);
List<ParameterDefinition> pds = pdp.getParameterDefinitions();
for (ParameterDefinition pd : pds) {
if (this.isInstance(pd)) {
return (DynamicParameter) pd;
}
}
}

I can add some hidden variables and get them passed as a query
parameter to my doFillValueItems method to help alleviate the problem
of only being able to use one of my type of parameter but I think if
someone can show me a better way to get back to the instance from the
descriptor that problem may go away.

The latest code has been committed and pushed to
https://github.com/tekante/Dynamic-Jenkins-Parameter

Thanks,
Chris

Tekante

unread,
Mar 19, 2012, 7:07:16 PM3/19/12
to Jenkins Developers
I've finished the initial version of this plugin and resolved the
issue where only one instance of this parameter type was allowed per
job. The plugin is documented at https://github.com/tekante/Dynamic-Jenkins-Parameter/wiki

I think this serves mostly as an example of how this type of plugin
could be written but if others think it is useful on its own let me
know and I'll work on getting it cleaned up and into the community
repository.

Chris
Message has been deleted

Salut

unread,
Apr 18, 2012, 7:02:31 AM4/18/12
to Jenkins Developers
Hi , I dont think its look and feel which you described in the WIKI is
the same as actual. There is no Name/Options mapping. Rather it just
asks for either choice or remote script.

The screenshots given in the link

https://wiki.jenkins-ci.org/display/JENKINS/Jenkins+Dynamic+Parameter+Plug-in

and

https://github.com/tekante/Dynamic-Jenkins-Parameter/wiki

are looking different. Are they different plugins altogether?

On Mar 20, 4:07 am, Tekante <teka...@gmail.com> wrote:
> I've finished the initial version of this plugin and resolved the
> issue where only one instance of thisparametertype was allowed per
> job. The plugin is documented athttps://github.com/tekante/Dynamic-Jenkins-Parameter/wiki

mail4m....@googlemail.com

unread,
Jun 18, 2014, 1:29:14 PM6/18/14
to jenkin...@googlegroups.com
Hi Tekante,

I am interested in your plugin and wonder whether I could ask you for some help with it?
I am having problems installing / building your plugin / code. Netbeans tells me there is an
unresolvable error with some certificate and as I didn't find some .jpi file and the folder structure of the plugin
seems to be deprecated I wonder whether you also have an up-to-date version of your plugin, running with the latest
Jenkins ?
I would be really really interested and grateful if you could provide some help with this.

Thanks in advance,

mmm
Reply all
Reply to author
Forward
0 new messages