Jenkins Jelly f:property propertyDescriptor attribute

378 views Asked by At

I am having some trouble using Jenkins property.jelly propertyDescriptor field. After doing some research, I found the propertyDescriptor attribute implementation is confusing.

Here is the code:

property.jelly file

See this line:

<j:set var="descriptor" value="${attrs.propertyDescriptor ?: app.getDescriptorOrDie(descriptor.getPropertyTypeOrDie(instance,field).clazz)}" />

I assume that ?: is the ternary operator in Jelly? However, it essentially says: if ${attrs.propertyDescriptor} is set, set "descriptor" to nothing, otherwise set "descriptor" to app.getDescriptorOrDie( ... )

Shouldn't it be:

<j:set var="descriptor" value="${attrs.propertyDescriptor ? ${attrs.propertyDescriptor : app.getDescriptorOrDie(descriptor.getPropertyTypeOrDie(instance,field).clazz)}" />
Note the code I inserted between ? and :.

Is this a bug in property.jelly?

1

There are 1 answers

0
Wei On

I think I have got the answer, it's called Elvis operator