How to render a data map object from servlet to a soy template config form of Bitbucket pre-receive hook

I wanted to pre-populate multiselect options in the config form of soy template with map values rendered by a servlet. Is this possible?

Define the servlet in the atlassian-plugin.xml file and specify the <url-pattern>. More details here. e.g.

<servlet key="my-servlet" class="com.example.MyServlet">

You should then be able to access it from js via ${BITBUCKET_URL}/plugins/servlet/my-servlet.

To pass data to your Soy template to pre-populate a multi-select (or a form), you can do so by providing the data to your render method on the Servlet class. Then, use that data in your Soy template to set HTML attributes and props. Alternatively, you can inject this data into a in the template and set the value of the multi-select using Javascript.

Thank you for the solution. I will try this. Currently I have just hardcoded the multi-select option values in the soy template. However validation of the config edit form in my pre-receive hook fails with error as Settings can accept only String, boolean or numerical . How can I validate multiple options selected by implementing Validation method of SettingsValidator interface? Is there any other means I can obtain the multiselected values to validate as the default save button of the hook edit form invokes Validation method of SettingsValidator which is not accepting multiselected options but accepts single selected value.