Json – Groovy with extended choice parameter plugin

boongroovyJenkinsjenkins-pluginsjson

I am trying to cook up a Groovy script to use with the Extended Choice Parameter plugin in Jenkins: https://wiki.jenkins-ci.org/display/JENKINS/Extended+Choice+Parameter+plugin.

From the plugin page: the groovy script should return a JSON object that corresponds to the "options" object referred to in https://github.com/jdorn/json-editor. The example script does not work and throws error.

Could someone tell me how I can have Boon.fromJSON() return a JSON editor object? My intention is to have a pre-defined set values beings shown as parameters, each accepting a text against it (i.e, render as textbox).

Example (following the JSON editor way):

{
  "value1": "",
  "value2": "",
  "value3": ""
}

Even if it can be done without using Boon parser, it should be fine.

Best Answer

It's important to note that Boon.fromJSON() takes a String as an argument. The example at the plugin page isn't very clear to someone who may not know groovy very well:

def jsonEditorOptions = Boon.fromJSON(/{
    disable_edit_json: true,
    ...
}/);

The /text/ syntax in groovy is the Slashy String. Disregard this if you are already using this syntax but you haven't provided your code or error received.

Related Topic