jenkinsjenkins-pluginsdescriptorjelly

Jenkins plugin descriptor with nested parameters


I'm writing descriptors for somebody else's pipeline steps jenkins plugin. Most steps are straight forward, e.g.

mySimpleStep(param1: value1, param2: value2)

However one of the steps requires a parameter, which is a map of two other values, so the actual call syntax is the following:

myOtherStep(param1: value1, param2: [sub1: value2, sub2: value3])

I can't fathom how to specify the parameters in the config.jelly file for the step and/or update the actual Step class so that the call syntax is created correctly. How can I do that?

(param2 class does have its own @DataBoundConstructor if it matter)

Do note that this is somebody else's plugin, I am in no position to change the actual plugin.


Solution

  • After almost giving up, I stumbled upon the answer while looking at the source code of Microsoft Azure Storage plugin. Here are the steps I needed to do.

    1. Ensure that the class of param2 implements Step and add Description inner class to it. It also needs to have a @DataBoundConstructor

    2. Create a separate descriptor directory for the class in resources with its own config.jelly and help-*.html files

    3. Change the config.jelly of myOtherStep to have something like this:

      <f:section title="General">
          <f:entry field="value1" title="First param" description="Simple parameter">
              <f:textbox/>
          </f:entry>
      
          <f:property field="value2">
              <st:include page="config.jelly"/>
          </f:property>
      
      </f:section>
      

    Now the config.jelly class for the complex parameter will be included - and everything works as expected.