Hi Roger,
That is for taking the options from a nested JSON block. So, you will reference that in the same way {option.option_name.value}. In this context, “value” isn’t the value name, is the Rundeck variable to refer to the value on the key/value structure.
e.g:
Job definition:
- defaultTab: nodes description: '' executionEnabled: true id: f7f8039a-17ff-4bbe-a683-95a25b739018 loglevel: INFO name: Cascade nodeFilterEditable: false options: - name: opt1 valuesUrl: file:/home/user/parent.json - name: brands valuesUrl: file:/home/user/${option.opt1.value} plugins: ExecutionLifecycle: {} scheduleEnabled: true sequence: commands: - exec: echo ${option.ropt} keepgoing: false strategy: node-first uuid: f7f8039a-17ff-4bbe-a683-95a25b739018See that “value” is the variable to access the value of the JSON registry, not the name “value”.
parent.json JSON file:
{ "brands": "brands.json", "services": "services.json" }services.json JSON file:
{ "service_1": "Service1", "service_2": "Service2", "service_3": "Service3" }brands.json JSON file:
{ "brand_1": "Brand1", "brand_2": "Brand2", "brand_3": "Brand3" }Now, I have been testing this specific way to use options (nested) and it works only on HTTP remote options, I think that should be working on file options too. I’ll file a new issue related.
Regards.
My bad, wrong job definition in my last post, this is the right one:
- defaultTab: nodes description: '' executionEnabled: true id: f7f8039a-17ff-4bbe-a683-95a25b739018 loglevel: INFO name: Cascade nodeFilterEditable: false options: - enforced: true name: opt1 valuesUrl: file:/home/user/parent.json - enforced: true name: brands valuesUrl: file:/home/user/${option.opt1.value} plugins: ExecutionLifecycle: {} scheduleEnabled: true sequence: commands: - exec: echo ${option.brands} keepgoing: false strategy: node-first uuid: f7f8039a-17ff-4bbe-a683-95a25b739018That was to demonstrate that the variable “value” (${option.my_opt.value}) refers to the JSON value, not the value name provided in the JSON file.
Regards.
Hi Roger,
In that scenario, Rundeck uses the first registry element as a key and the second as the value. After some experimentation, I realized that I had forgotten a “workaround” for selecting several items as keys.
The “trick” is to set the second option to “multiple-valued” followed by a comma. In that way, you can select numerous alternatives; however, unlike your original request, this method requires you to include every option provided in the JSON file as registers.
parent.json JSON file:
{ "brands": "brands.json", "services": "services.json" }services.json JSON file:
{ "service_1": "Service1", "service_2": "Service2", "service_3": "Service3" }brands.json JSON file:
{ "brand_1": "Brand1", "brand_2": "Brand2", "brand_3": "Brand3" }Job definition
- defaultTab: nodes description: '' executionEnabled: true id: 0e388143-065a-426b-9cf3-911aaf2405a2 loglevel: INFO name: HelloWorld nodeFilterEditable: false options: - enforced: true name: parent value: services valuesUrl: file:/home/user/parent.json - delimiter: ',' multivalued: true name: select values: - file:/home/user/${option.parent.value} valuesListDelimiter: ',' valuesUrl: file:/home/user/${option.parent.value} plugins: ExecutionLifecycle: {} scheduleEnabled: true sequence: commands: - exec: 'echo "selected items: ${option.select}"' keepgoing: false strategy: node-first uuid: 0e388143-065a-426b-9cf3-911aaf2405a2See how to select multiple elements and the job result.
Hope it helps.