[JIRA] [workflow-plugin] (JENKINS-34590) Fail to generate correct input step with choice param syntax from snippet generator

4 views
Skip to first unread message

amuniz@cloudbees.com (JIRA)

unread,
May 4, 2016, 4:43:01 AM5/4/16
to jenkinsc...@googlegroups.com
Antonio Muñiz created an issue
 
Jenkins / Bug JENKINS-34590
Fail to generate correct input step with choice param syntax from snippet generator
Issue Type: Bug Bug
Assignee: Jesse Glick
Components: workflow-plugin
Created: 2016/May/04 8:42 AM
Priority: Major Major
Reporter: Antonio Muñiz

Snippet generator generates this for input step with choice parameters:

input message: '', parameters: [[$class: 'ChoiceParameterDefinition', choices: ['option1', 'option2'], description: '', name: 'My param']]

That code tries to use the @DataboundConstructor of ChoiceParameterDefinition which does not match with the required signature, thus this warning stack trace is shown on snippet generation time:

May 04, 2016 10:25:46 AM org.jenkinsci.plugins.structs.describable.DescribableModel uninstantiate
WARNING: Cannot create control version of class hudson.model.ChoiceParameterDefinition using {choices=[option1, option2], description=, name=select}
java.lang.ClassCastException: hudson.model.ChoiceParameterDefinition.choices expects class java.lang.String but received class java.util.Arrays$ArrayList
	at org.jenkinsci.plugins.structs.describable.DescribableModel.coerce(DescribableModel.java:317)
	at org.jenkinsci.plugins.structs.describable.DescribableModel.buildArguments(DescribableModel.java:248)
	at org.jenkinsci.plugins.structs.describable.DescribableModel.instantiate(DescribableModel.java:192)
	at org.jenkinsci.plugins.structs.describable.DescribableModel.uninstantiate(DescribableModel.java:440)
	at org.jenkinsci.plugins.structs.describable.DescribableModel.uninstantiate_(DescribableModel.java:466)
	at org.jenkinsci.plugins.structs.describable.DescribableParameter.uncoerce(DescribableParameter.java:164)
	at org.jenkinsci.plugins.structs.describable.DescribableParameter.uncoerce(DescribableParameter.java:158)
	at org.jenkinsci.plugins.structs.describable.DescribableParameter.inspect(DescribableParameter.java:112)
	at org.jenkinsci.plugins.structs.describable.DescribableModel.uninstantiate(DescribableModel.java:426)
	at org.jenkinsci.plugins.structs.describable.DescribableModel.uninstantiate_(DescribableModel.java:466)
	at org.jenkinsci.plugins.workflow.steps.StepDescriptor.defineArguments(StepDescriptor.java:114)
	at org.jenkinsci.plugins.workflow.cps.Snippetizer.object2Groovy(Snippetizer.java:68)
	at org.jenkinsci.plugins.workflow.cps.Snippetizer.doGenerateSnippet(Snippetizer.java:218)

The generated snippet does not work later on runtime, throwing the same exception.

Add Comment Add Comment
 
This message was sent by Atlassian JIRA (v6.4.2#64017-sha1:e244265)
Atlassian logo

amuniz@cloudbees.com (JIRA)

unread,
May 4, 2016, 4:44:01 AM5/4/16
to jenkinsc...@googlegroups.com
Antonio Muñiz commented on Bug JENKINS-34590
 
Re: Fail to generate correct input step with choice param syntax from snippet generator

Workaround: use this instead of the snippet generation code.

choice = new ChoiceParameterDefinition('Param name', ['option1', 'option2'] as String[], 'Description')
input message: 'Select one', parameters: [choice]

pwolf@cloudbees.com (JIRA)

unread,
May 4, 2016, 11:23:03 AM5/4/16
to jenkinsc...@googlegroups.com

I think this is a duplicate ticket that was already filed. Do you know the original ticket on this Daniel Beck?

pwolf@cloudbees.com (JIRA)

unread,
May 4, 2016, 12:02:02 PM5/4/16
to jenkinsc...@googlegroups.com
Patrick Wolf edited a comment on Bug JENKINS-34590
I think this is a duplicate ticket that was already filed. Do you know the original ticket on this [~danielbeck]?

Is this the same issue?
https://issues.jenkins-ci.org/browse/JENKINS-29711

amuniz@cloudbees.com (JIRA)

unread,
May 4, 2016, 12:13:02 PM5/4/16
to jenkinsc...@googlegroups.com

Patrick Wolf I don't think so. This one is about the snippet generator picking up a wrong constructor.

dbeck@cloudbees.com (JIRA)

unread,
May 4, 2016, 12:33:01 PM5/4/16
to jenkinsc...@googlegroups.com

Patrick Wolf No, this one is specific to the ChoiceParameterDefinition type and inconsistency in its definition. Looks more like JENKINS-26143.

amuniz@cloudbees.com (JIRA)

unread,
May 4, 2016, 12:36:03 PM5/4/16
to jenkinsc...@googlegroups.com

amuniz@cloudbees.com (JIRA)

unread,
May 4, 2016, 12:36:05 PM5/4/16
to jenkinsc...@googlegroups.com

dbeck@cloudbees.com (JIRA)

unread,
May 4, 2016, 1:27:02 PM5/4/16
to jenkinsc...@googlegroups.com

dbeck@cloudbees.com (JIRA)

unread,
May 4, 2016, 1:27:03 PM5/4/16
to jenkinsc...@googlegroups.com
Daniel Beck resolved as Duplicate
Change By: Daniel Beck
Status: Reopened Resolved
Resolution: Duplicate

gael.stehagen@gmail.com (JIRA)

unread,
Dec 23, 2016, 11:11:03 AM12/23/16
to jenkinsc...@googlegroups.com
Gael Stehagen commented on Bug JENKINS-34590
 
Re: Fail to generate correct input step with choice param syntax from snippet generator

In case people are coming here as I did. I resolved it with using default snippet from current generator, but instead of the created array, I used the string option with inline line breaks. Otherwise I had to get the 'new ChoiceParameterDefinition(...)' method whitelisted.

So I ended up with:
...

choice(choices: "option1\noption2\noption3\n", description: 'delimiters within string', name: 'my param'),
This message was sent by Atlassian JIRA (v7.1.7#71011-sha1:2526d7c)
Atlassian logo

nicolas.brosse.mail@gmail.com (JIRA)

unread,
Jan 19, 2017, 5:32:02 AM1/19/17
to jenkinsc...@googlegroups.com
BRSSE Nicolas updated an issue
 
Change By: BRSSE Nicolas
Attachment: Capture d’écran 2017-01-19 à 11.30.46.png

nicolas.brosse.mail@gmail.com (JIRA)

unread,
Jan 19, 2017, 5:34:01 AM1/19/17
to jenkinsc...@googlegroups.com
BRSSE Nicolas commented on Bug JENKINS-34590
 
Re: Fail to generate correct input step with choice param syntax from snippet generator

Thank you it works

However, the pipeline syntax does not generate the correct syntax.

My version of jenkins is 2.41

dbeck@cloudbees.com (JIRA)

unread,
Jan 19, 2017, 9:00:01 AM1/19/17
to jenkinsc...@googlegroups.com

BROSSE Nicolas Unclear what you're saying. Note that this is resolved as duplicate of another issue, so it is known that the snippet generator is wrong.

Reply all
Reply to author
Forward
0 new messages