Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Fill in a ArrayList within a configuration jelly file for a Jenkins Plugin

I have a problem when trying to implement the configuration file of my plugin. I started my program with the already existing SideBar Plugin, but I encountered a problem when I added a List<String> as a variable to the class Action : private List<String> projects; How can I fill such a list within the jelly file?

I tried doing as such :

<f:entry>
 <f:optionalBlock title="Project to be considered :">
  <f:repeatable var="project" items="${link.projects}" name="projects" add="Add a project">
   <f:entry title="Project 1 :">
   </f:entry>
  </f:repeatable>      
 </f:optionalBlock>
</f:entry>

I added these lines in the links.jelly file, but it doesn't work.

If anyone knows how to do this, it would be great.

Thank you

like image 358
Mtrompe Avatar asked Oct 07 '22 20:10

Mtrompe


1 Answers

The list in your action should have a type (also for better reading)

private List<YourObject> projects

Then your config.jelly can look like this:

<f:repeatable var="projectInList" name="projects" items="${instance.projects}" noAddButton="true" minimum="0">
    <fieldset>
        <f:entry title="${%Project}" description="Project desc." 
                                field="variableInProjectObject">
            <f:textbox value="${projectInList.variableInProjectObject}" default="" />
        </f:entry>
    </fieldset>
</f:repeatable>
like image 158
iwan.z Avatar answered Oct 10 '22 10:10

iwan.z