How can I reference full qualified class name in Jenkins Jelly file?

24 views
Skip to first unread message

Cheng Bao

unread,
Sep 8, 2016, 4:36:28 PM9/8/16
to Jenkins Developers

In Jenkins jelly file, I have need to use java class object from class name.

<j:set var="myProperty" value="${job.getProperty(MyProperty.class)}" />

MyProperty is my custom JobProperty class, which is applied to job However, the above line will not work properly, even I tried

<j:set var="myClass" value="${MyProperty.class}" />

or

<j:set var="myClass" value="${full.qualified.class.MyProperty.class}" />

myClass object will always been null.

How I can use class object from jelly?

Jesse Glick

unread,
Sep 8, 2016, 11:05:24 PM9/8/16
to Jenkins Dev
On Thu, Sep 8, 2016 at 4:36 PM, Cheng Bao <cb...@vmware.com> wrote:
> How I can use class object from jelly?

Not easily if at all.

Either switch to a Groovy view; or (my general preference) extract any
logic that is not absolutely trivial into helper methods in Java code
which can be called as instance methods with simply-typed parameters
from something the Jelly view already has available (`it`,
`descriptor`, etc.).

Cheng Bao

unread,
Sep 9, 2016, 2:15:44 PM9/9/16
to Jenkins Developers
Hi, thanks, 
writing helper methods is my current workaround. I am looking into groovy.
Reply all
Reply to author
Forward
0 new messages