Reputation: 1813
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.
Upvotes: 0
Views: 8199
Reputation: 345
There is a typo in the example on the wiki page.
Use Boon.fromJson instead of Boon.fromJSON.
Below is an example to render an editor on Jenkins page
import org.boon.Boon;
def jsonEditorOptions = Boon.fromJson(/{
disable_edit_json: true,
disable_properties: true,
no_additional_properties: true,
disable_collapse: true,
disable_array_add: true,
disable_array_delete: true,
disable_array_reorder: true,
theme: "bootstrap2",
iconlib:"fontawesome4",
schema: {
"title": "Color Picker",
"type": "object",
"properties": {
"color": {
"type": "string",
"format": "color"
}
}
},
startval: {
color :"red"
}
}/);
Upvotes: 1
Reputation: 1870
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.
Upvotes: 1