jenkinsjenkins-plugins

Active Choices Parameter usage with Active Choices Reactive Parameter


i am trying to have one active choice parameter that called pg1 as shown below with checkboxes value enter image description here

and the second Active Choices Reactive Parameter depend on it so whatever i chose in the first parameter it should be removed from the checkbox values in this parameter enter image description here

so the issue now when i check one box in pg1 it will be removed from pg2 but if i select multiple then pg2 show all. from what i understand it seems the list will be created as ["eht1,eth2"] as single value list always. how i can solve this? i try to slpit it but it wont work should i convert it to string and then split?


Solution

  • I was able to make it working with following changes.

    def pg1 = (PG1_PORTS instanceof List) ? PG1_PORTS : PG1_PORTS.split(",").collect{it}
    def allPorts =  ["eth1","eth2","eth3","eth4"]
    def availablePorts = allPorts - pg1
    return availablePorts
    

    If you open Browser Dev Tools(F12) and check the console and network calls going to server when you select PG1_PORTS, its actually sending a String with comma separated selection of values.

    So PG1_PORTS.split(",").collect{it} will split string into array and collect the values.

    enter image description here