Maybe I'm not looking in the right places or I just don't understand the 
code but I cannot see how to get an optionalProperty to work.  The only 
example I can find this the ui-samples-plugin which has an overly 
complicated example that I cannot follow.

1. Do you have any advice on how to search existing plugin code for 
optionalProperty usage?  Google isn't that helpful...

2. Can you either:

   - point me at a plugin that has a simple implementation that I could use 
   to adapt the following code 


   - suggest what changes I need to make to convert the following 
   optionalBlock to an optionalProperty? 




<f:optionalBlock title="Set Build Variables in BuildMaster" 
field="setBuildVariables" >
    <f:entry title="Copy Previous Build's Variables" 
field="preserveVariables" >
        <f:checkbox default="false" />
    <f:entry title="Variables" field="variables" >
        <f:expandableTextbox /> 


*Class Snippet*

public final void setSetBuildVariables(SetBuildVariables setBuildVariables) 
    if (setBuildVariables != null) {
        this.setBuildVariables = true;
        this.preserveVariables = setBuildVariables.preserveVariables;
        this.variables = setBuildVariables.variables;
    } else {
        this.setBuildVariables = false;
        this.preserveVariables = false;
        this.variables = null;
public static final class SetBuildVariables {
    private final boolean preserveVariables;
    private final String variables;

    public SetBuildVariables(boolean preserveVariables, String variables) {
        this.preserveVariables = preserveVariables;
        this.variables = variables;


Thanks in advance


On Thursday, January 19, 2017 at 5:13:37 AM UTC+13, Jesse Glick wrote:
> On Tue, Jan 17, 2017 at 7:55 PM,  < <javascript:>> 
> wrote: 
> > When updating a plugin to support pipeline script, how do I handle an 
> > optionalBlock section? 
> Do not use `f:optionalBlock`. This is a low-level control. Do not 
> refer to `JSONObject` either. All this is old-style deprecated form 
> binding. 
> Use a high-level control like `f:optionalProperty` for nullable 
> structs (`ui-samples-plugin` has an example), or simple independent 
> `f:checkbox`es for `boolean` properties (`doCheck*` form validation 
> can reject invalid combinations). 
> Also use `@DataBoundSetter` for any property with a plausible default. 

You received this message because you are subscribed to the Google Groups 
"Jenkins Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
To view this discussion on the web visit
For more options, visit

Reply via email to