java.lang.Object in new pipeline command causing snippetizer to fall over, is there an annotation?

13 views
Skip to first unread message

Michael Carter

unread,
Jul 13, 2020, 12:44:54 PM7/13/20
to Jenkins Developers
Caused by: java.lang.IllegalArgumentException: Unable to convert to class java.lang.Object
    at org.kohsuke.stapler.RequestImpl$TypePair.convertJSON (RequestImpl.java:738)

Caused by: java.lang.Error: Failed to instantiate class io.jenkins.plugins.****
    at hudson.model.Descriptor.newInstance (Descriptor.java:606)
    at org.jenkinsci.plugins.workflow.cps.Snippetizer.doGenerateSnippet (Snippetizer.java:502)
    at java.lang.invoke.MethodHandle.invokeWithArguments (MethodHandle.java:627)


So basically I have an java.lang.Object field and snippetizer falls over on the "generate command"

Is there an annotation or something to say tell snippetizer to use this Object as a string?   As the generator command will be a String but in script it could be a Json object or other things.

Bottom line is I wanted to have a single input field that could be mutiple types.

... and if anyone asks no I can't share the source.  It's part of an inhouse plugin and it's not something I'm allowed to share. 

Jesse Glick

unread,
Jul 13, 2020, 4:39:24 PM7/13/20
to Jenkins Dev
On Mon, Jul 13, 2020 at 12:44 PM Michael Carter
<mikeyca...@gmail.com> wrote:
> Is there an annotation or something to say tell snippetizer to use this Object as a string?

No. `Object` is not supported for databinding purposes.

> Bottom line is I wanted to have a single input field that could be mutiple types.

Define a subtype of `Describable`.

https://www.jenkins.io/doc/developer/plugin-development/pipeline-integration/
Reply all
Reply to author
Forward
0 new messages