3

I'll keep this short and sweet. I'm trying to use jdorn's JSON editor through the use of the Extended Choice Plugin on Jenkins to create a node selection tool for code deployments.

The part I'm stuck on is getting the node choices to be dependent on which environment the user selects.

Here is what it will look like in the end: Example UI

The goal is to have the "Node" field watch the "Environment" field and use that value to pick the right definition that contains the list of nodes for that environment.

Here is the code I'm working on and and I hope someone will see what I'm trying to do and point out why it won't work:

{
    "title": "Node Selection",
    "type": "array",
    "format": "table",
    "uniqueItems": true,
    "items": {
        "type": "object",
        "title": "Environment",
        "properties": {
            "Environment": {
                "propertyOrder": 1,
                "title": "Environment",
                "type": "string",
                "enum": [
                    "tst01",
                    "dev01"
                ]
            },
            "Nodes": {
                "title": "Nodes",
                "propertyOrder": 2,
                "type": "array",
                "format": "checkbox",
                "uniqueItems": true,
                "watch": {
                    "env": "Environment"
                },
                "items": {
                    "type": "string",
                    "$ref": "#/definitions/{{env}}"
                }
            }
        },
        "definitions": {
            "tst01": {
                "enum": [
                    "server1",
                    "server2",
                    "server3",
                    "server4"
                ]
            },
            "dev01": {
                "enum": [
                    "server5",
                    "server6",
                    "server7",
                    "server8"
                ]
            }
        }
    }
}

0 Answers0